Submission #6906447
Source Code Expand
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd(b,a%b); } } long long lcm(long long x, long long y){ return (x/gcd(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; int main(){ string s; int k; cin>>s; cin>>k; int n; n = s.size(); int temp; int templ; string t =""; REP(i,n){ if(i==n-1){ temp = k%26; templ = s[i]-'a'; char last = 'a' + (temp+templ)%26; t += last; continue; } temp = s[i]-'a'; if(k>=(26-temp)){ k -= 26-temp; t += "a"; }else{ t += s[i]; } } cout<<t<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Next Letter |
User | ready_player074 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2721 Byte |
Status | WA |
Exec Time | 5 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 5 ms | 640 KB |
1_07.txt | AC | 5 ms | 640 KB |
1_08.txt | WA | 5 ms | 640 KB |
1_09.txt | WA | 5 ms | 640 KB |
1_10.txt | WA | 5 ms | 640 KB |
1_11.txt | WA | 5 ms | 640 KB |
1_12.txt | WA | 5 ms | 640 KB |
1_13.txt | WA | 5 ms | 640 KB |
1_14.txt | WA | 5 ms | 640 KB |
1_15.txt | WA | 5 ms | 640 KB |
1_16.txt | AC | 5 ms | 640 KB |
1_17.txt | AC | 5 ms | 640 KB |
1_18.txt | AC | 5 ms | 640 KB |
1_19.txt | AC | 5 ms | 640 KB |
1_20.txt | AC | 5 ms | 640 KB |
1_21.txt | AC | 5 ms | 640 KB |
1_22.txt | AC | 5 ms | 640 KB |
1_23.txt | AC | 5 ms | 640 KB |