# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
330944 |
2020-11-27T00:16:07 Z |
MetB |
Shift (POI11_prz) |
C++14 |
|
324 ms |
19508 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const int N = 2000001;
const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;
struct cyclic_array {
vector <int> v;
int shift, n;
cyclic_array(int n)
: v (vector <int> (n)), shift (0), n (n) {}
void make_b() {
shift = shift ? shift - 1 : n - 1;
}
void make_a() {
int& a = v[shift % n];
int& b = v[(shift + 1) % n];
int& c = v[(shift + 2) % n];
swap(b, c), swap(a, b);
}
int& operator[] (int x) {
return v[(x + shift) % n];
}
};
vector <pair<int, char>> s;
int n;
void add_a(cyclic_array& v) {
v.make_a();
if (!s.empty() && s.back().second == 'a') s.back().first++;
else s.push_back({1, 'a'});
}
void add_b(cyclic_array& v) {
v.make_b();
if (!s.empty() && s.back().second == 'b') s.back().first++;
else s.push_back({1, 'b'});
}
int main () {
cin >> n;
cyclic_array v (n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 2; i <= n; i++) {
while (v[2] != i) add_b(v);
while (v[0] != i - 1 && v[1] != i - 1) {
add_a(v), add_b(v), add_b(v);
}
if (v[0] == i - 1 && i == n - 1) {
cout << "NIE DA SIE";
return 0;
}
}
while (v[0] != 1) add_b(v);
cout << s.size () << endl;
for(auto ch : s) {
cout << ch.first % n << ch.second << ' ';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Liczby nie zostaly posortowane |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "NIE" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
496 KB |
Expected integer, but "NIE" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1508 KB |
Expected integer, but "NIE" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
16840 KB |
Expected integer, but "NIE" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
16864 KB |
Expected integer, but "NIE" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
324 ms |
19508 KB |
Liczby nie zostaly posortowane |
2 |
Halted |
0 ms |
0 KB |
- |