Submission #1370419
Source Code Expand
/** Template created by Danel Batyrbek All rights are reserved 2017 (lol) */ #include <bits/stdc++.h> #define speed_up ios_base :: sync_with_stdio(0);cin.tie(0) #define fr first #define sc second #define mkp make_pair #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define debug(x) cerr << x << '\n'; #define YES "YES" #define NO "NO" #define skip continue #define left(x) x << 1 #define rght(x) x << 1 | 1 #define forn(x, y, z) for(int x = y; x <= z; ++ x) #define for1(x, y, z) for(int x = y; x >= z; -- x) #define fname "" using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef double ld; const int N = 1e5 + 10; const int mod = 1e9 + 7; const int N3 = 1e3 + 10; const int INF = 2e9 + 10; const ll LINF = 2e18; int n, k, cycle; string s; map <string, int> mp; char A = 'A', B = 'B'; int main(){ #ifndef DEBUG if(fname != ""){ freopen(fname".in", "r", stdin); freopen(fname".out", "w", stdout); } #endif speed_up; cin >> n >> k; cin >> s; mp[s] = 1; forn(i, 1, k){ if(s[0] == A){ s[0] = B; skip; } forn(j, 1, n - 1){ if(s[j - 1] == B && s[j] == B){ s[j - 1] = A; } else if(s[j - 1] == B && s[j] == A){ s[j] = B; } else if(s[j - 1] == A && s[j] == B){ skip; } } s[n - 1] = A; if(mp[s]){ cycle = (i + 1) - mp[s]; k %= cycle; } else { mp[s] = i + 1; } } cout << s; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Half Reflector |
User | KtlTheBest |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1493 Byte |
Status | TLE |
Exec Time | 2156 ms |
Memory | 811540 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:44:33: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result] freopen(fname".in", "r", stdin); ^ ./Main.cpp:45:35: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result] freopen(fname".out", "w", stdout); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 900 | ||||||
Status |
|
|
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 | 2 ms | 384 KB |
in10.txt | TLE | 2153 ms | 775060 KB |
in11.txt | TLE | 2123 ms | 297620 KB |
in12.txt | TLE | 2153 ms | 766228 KB |
in13.txt | TLE | 2152 ms | 775060 KB |
in14.txt | TLE | 2124 ms | 297108 KB |
in15.txt | TLE | 2153 ms | 765332 KB |
in16.txt | TLE | 2155 ms | 808980 KB |
in17.txt | TLE | 2124 ms | 296212 KB |
in18.txt | TLE | 2147 ms | 651796 KB |
in19.txt | TLE | 2156 ms | 811540 KB |
in2.txt | TLE | 2126 ms | 298320 KB |
in20.txt | TLE | 2124 ms | 297108 KB |
in21.txt | TLE | 2147 ms | 597012 KB |
in22.txt | TLE | 2124 ms | 296724 KB |
in23.txt | TLE | 2124 ms | 297492 KB |
in24.txt | TLE | 2124 ms | 297748 KB |
in25.txt | TLE | 2125 ms | 297108 KB |
in26.txt | TLE | 2124 ms | 297108 KB |
in27.txt | TLE | 2124 ms | 297492 KB |
in28.txt | TLE | 2124 ms | 296980 KB |
in29.txt | TLE | 2124 ms | 297492 KB |
in3.txt | TLE | 2123 ms | 296980 KB |
in30.txt | TLE | 2124 ms | 297492 KB |
in31.txt | TLE | 2124 ms | 297108 KB |
in32.txt | TLE | 2124 ms | 297364 KB |
in33.txt | TLE | 2123 ms | 296596 KB |
in34.txt | TLE | 2124 ms | 297108 KB |
in35.txt | TLE | 2124 ms | 297364 KB |
in36.txt | TLE | 2124 ms | 297364 KB |
in37.txt | TLE | 2124 ms | 297748 KB |
in38.txt | TLE | 2123 ms | 296212 KB |
in39.txt | TLE | 2124 ms | 297364 KB |
in4.txt | TLE | 2124 ms | 296212 KB |
in40.txt | TLE | 2124 ms | 297108 KB |
in41.txt | TLE | 2123 ms | 296724 KB |
in42.txt | TLE | 2124 ms | 297364 KB |
in5.txt | TLE | 2126 ms | 297112 KB |
in543.txt | AC | 1026 ms | 143636 KB |
in557.txt | AC | 1030 ms | 144276 KB |
in6.txt | AC | 1 ms | 256 KB |
in7.txt | TLE | 2124 ms | 297492 KB |
in8.txt | TLE | 2124 ms | 297108 KB |
in9.txt | TLE | 2124 ms | 296980 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |