Submission #1512465


Source Code Expand

#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

const char ab=('A'^'B');


int main(void){
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;

	int flip = 0;
	deque<char> q;
	rep(i,n) q.push_back(s[i]);

	rep(loop,2*n){
		if(k==0) break;
		k--;
		char cur = (flip?q.front()^ab:q.front());
		
		if(cur=='A'){
			char nxt = (flip?'A':'B');
			q.pop_front();
			q.push_front(nxt);
		}else{
			flip^=1;
			char nxt = (flip?'B':'A');
			q.pop_front();
			q.push_back(nxt);
		}
	}

	string ans ="";
	rep(i,n){
		char cur = (flip?q.front()^ab:q.front());
		ans += cur;
		q.pop_front();
	}
		
	if(n%2 == 1 and k%2==1) ans[0]^=ab; 
	cout << ans << endl;

	return 0;
}

Submission Info

Submission Time
Task D - Half Reflector
User Hec
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1843 Byte
Status AC
Exec Time 11 ms
Memory 1164 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 3
AC × 50
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in4.txt, in40.txt, in41.txt, in42.txt, in5.txt, in543.txt, in557.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
in1.txt AC 1 ms 256 KB
in10.txt AC 10 ms 1164 KB
in11.txt AC 11 ms 1164 KB
in12.txt AC 10 ms 1164 KB
in13.txt AC 10 ms 1164 KB
in14.txt AC 11 ms 1164 KB
in15.txt AC 10 ms 1164 KB
in16.txt AC 10 ms 1164 KB
in17.txt AC 10 ms 1164 KB
in18.txt AC 10 ms 1164 KB
in19.txt AC 10 ms 1164 KB
in2.txt AC 5 ms 768 KB
in20.txt AC 10 ms 1164 KB
in21.txt AC 10 ms 1164 KB
in22.txt AC 11 ms 1164 KB
in23.txt AC 11 ms 1164 KB
in24.txt AC 11 ms 1164 KB
in25.txt AC 11 ms 1164 KB
in26.txt AC 11 ms 1164 KB
in27.txt AC 11 ms 1164 KB
in28.txt AC 10 ms 1164 KB
in29.txt AC 10 ms 1164 KB
in3.txt AC 10 ms 1164 KB
in30.txt AC 10 ms 1164 KB
in31.txt AC 10 ms 1164 KB
in32.txt AC 10 ms 1164 KB
in33.txt AC 10 ms 1164 KB
in34.txt AC 10 ms 1164 KB
in35.txt AC 11 ms 1164 KB
in36.txt AC 11 ms 1164 KB
in37.txt AC 11 ms 1164 KB
in38.txt AC 11 ms 1164 KB
in39.txt AC 10 ms 1164 KB
in4.txt AC 11 ms 1164 KB
in40.txt AC 10 ms 1164 KB
in41.txt AC 10 ms 1164 KB
in42.txt AC 10 ms 1164 KB
in5.txt AC 11 ms 1164 KB
in543.txt AC 9 ms 1072 KB
in557.txt AC 9 ms 1072 KB
in6.txt AC 1 ms 256 KB
in7.txt AC 10 ms 1164 KB
in8.txt AC 11 ms 1164 KB
in9.txt AC 10 ms 1164 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB