CODE FESTIVAL 2016 qual A

Submission #1227904

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char c[MAXN];

void solve(){
	int n, k;
	scanf("%s%d", &c[0], &k);
	n = strlen(c);
	REP(i, 0, n){
		if (c[i] != 'a'){
			int d = 26 - (c[i] - 'a');
			if (d <= k){
				c[i] = 'a';
				k -= d;
			}
		}
	}
	k %= 26;
	while(k--){
		c[n - 1]++;
		if (c[n - 1] > 'z'){
			c[n - 1] = 'a';
		}
	}
	printf("%s\n", c);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Submission

Task問題 C - 次のアルファベット / Next Letter
User nameユーザ名 Timur Sitdikov
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 1346 Byte
File nameファイル名
Exec time実行時間 2 ms
Memory usageメモリ使用量 384 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘void solve()’:
./Main.cpp:40:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s%d", &c[0], &k);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt
All 400 / 400 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 2 ms 384 KB
1_07.txt AC 2 ms 384 KB
1_08.txt AC 2 ms 384 KB
1_09.txt AC 2 ms 384 KB
1_10.txt AC 2 ms 384 KB
1_11.txt AC 2 ms 384 KB
1_12.txt AC 2 ms 384 KB
1_13.txt AC 2 ms 384 KB
1_14.txt AC 2 ms 384 KB
1_15.txt AC 2 ms 384 KB
1_16.txt AC 2 ms 384 KB
1_17.txt AC 2 ms 384 KB
1_18.txt AC 2 ms 384 KB
1_19.txt AC 2 ms 384 KB
1_20.txt AC 2 ms 384 KB
1_21.txt AC 2 ms 384 KB
1_22.txt AC 2 ms 384 KB
1_23.txt AC 2 ms 384 KB