#ifndef Nhoksocqt1
#include "Anna.h"
#endif // Nhoksocqt1
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
template<class X, class Y>
inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
const int MAXN = 100005;
int prv[MAXN], nxt[MAXN];
int pos[MAXN], tmp[MAXN], val[MAXN];
bool dx[MAXN];
#ifdef Nhoksocqt1
vector<int> sendedMessage;
void Send(int x) {
sendedMessage.push_back(x);
}
void Remove(int d) {
cout << "REMOVE AT POS: " << d << '\n';
}
#endif // Nhoksocqt1
void Anna(int n, vector<char> S) {
int l(0), r(n - 1);
for (int i = 0; i < n; ++i)
val[i] = (S[i] != 'X') + (S[i] == 'Z');
while(l <= r && val[l] != 0)
++l;
while(r >= l && val[r] != 2)
--r;
for (int i = 0; i < n; ++i)
dx[i] = 0;
if(l <= r)
dx[l] = dx[r] = 1;
for (int j = l + 1; j < r; ++j) {
while(j < r && val[j] == val[j + 1])
++j;
if(j < r && val[j] == 2)
dx[j] = 1;
}
for (int i = 0; i < n; ++i)
Send(dx[i]);
}
#ifdef Nhoksocqt1
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen("JOI21MACHINE.inp", "r", stdin);
freopen("JOI21MACHINE.out", "w", stdout);
vector<char> s;
int n;
cin >> n;
s.resize(n);
for (int i = 0; i < n; ++i) {
cin >> s[i];
//s[i] = Random(0, 2) + 'X'; cout << s[i];
}
//cout << '\n';
Anna(n, s);
cout << "SENDED MESSAGES: "; for (int it : sendedMessage) cout << it; cout << '\n';
Bruno(n, sz(sendedMessage), sendedMessage);
return 0;
}
#endif // Nhoksocqt1
#ifndef Nhoksocqt1
#include "Bruno.h"
#endif // Nhoksocqt1
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
template<class X, class Y>
inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
const int MAXN = 100005;
int prv[MAXN], nxt[MAXN];
int pos[MAXN], tmp[MAXN], val[MAXN];
bool dx[MAXN];
#ifdef Nhoksocqt1
vector<int> sendedMessage;
void Send(int x) {
sendedMessage.push_back(x);
}
void Remove(int d) {
cout << "REMOVE AT POS: " << d << '\n';
}
#endif // Nhoksocqt1
void Bruno(int N, int L, vector<int> A) {
for (int i = 0; i < N; ++i)
dx[i] = A[i];
int fl(-1), last(-1);
for (int i = 0; i < N; ++i) {
if(dx[i]) {
last = i + 1;
break;
}
Remove(i);
}
fl = last;
if(last < 0)
return;
for (int i = last; i < N; ++i) {
if(dx[i]) {
for (int j = i - 1; j >= last; --j)
Remove(j);
Remove(i);
last = i + 1;
}
}
Remove(fl - 1);
for (int i = last; i < N; ++i)
Remove(i);
}
#ifdef Nhoksocqt1
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen("JOI21MACHINE.inp", "r", stdin);
freopen("JOI21MACHINE.out", "w", stdout);
vector<char> s;
int n;
cin >> n;
s.resize(n);
for (int i = 0; i < n; ++i) {
cin >> s[i];
//s[i] = Random(0, 2) + 'X'; cout << s[i];
}
//cout << '\n';
Anna(n, s);
cout << "SENDED MESSAGES: "; for (int it : sendedMessage) cout << it; cout << '\n';
Bruno(n, sz(sendedMessage), sendedMessage);
return 0;
}
#endif // Nhoksocqt1
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
516 KB |
Output is correct |
2 |
Correct |
1 ms |
616 KB |
Output is correct |
3 |
Correct |
1 ms |
516 KB |
Output is correct |
4 |
Correct |
1 ms |
496 KB |
Output is correct |
5 |
Correct |
1 ms |
520 KB |
Output is correct |
6 |
Correct |
2 ms |
524 KB |
Output is correct |
7 |
Correct |
1 ms |
524 KB |
Output is correct |
8 |
Correct |
0 ms |
516 KB |
Output is correct |
9 |
Correct |
1 ms |
524 KB |
Output is correct |
10 |
Correct |
1 ms |
524 KB |
Output is correct |
11 |
Correct |
1 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
52 ms |
8716 KB |
Partially correct |
2 |
Partially correct |
61 ms |
8748 KB |
Partially correct |
3 |
Partially correct |
57 ms |
8680 KB |
Partially correct |
4 |
Partially correct |
55 ms |
8776 KB |
Partially correct |
5 |
Partially correct |
54 ms |
8720 KB |
Partially correct |
6 |
Partially correct |
60 ms |
8700 KB |
Partially correct |
7 |
Partially correct |
55 ms |
8736 KB |
Partially correct |
8 |
Partially correct |
53 ms |
8732 KB |
Partially correct |
9 |
Partially correct |
54 ms |
8640 KB |
Partially correct |
10 |
Partially correct |
59 ms |
8740 KB |
Partially correct |
11 |
Partially correct |
52 ms |
8692 KB |
Partially correct |
12 |
Partially correct |
54 ms |
8708 KB |
Partially correct |
13 |
Partially correct |
63 ms |
8744 KB |
Partially correct |
14 |
Partially correct |
67 ms |
8624 KB |
Partially correct |
15 |
Partially correct |
56 ms |
8636 KB |
Partially correct |
16 |
Partially correct |
64 ms |
8728 KB |
Partially correct |
17 |
Partially correct |
66 ms |
8752 KB |
Partially correct |
18 |
Partially correct |
65 ms |
8700 KB |
Partially correct |
19 |
Partially correct |
60 ms |
8656 KB |
Partially correct |
20 |
Partially correct |
55 ms |
8916 KB |
Partially correct |
21 |
Partially correct |
52 ms |
8920 KB |
Partially correct |
22 |
Partially correct |
74 ms |
8732 KB |
Partially correct |
23 |
Partially correct |
55 ms |
8652 KB |
Partially correct |
24 |
Partially correct |
55 ms |
8656 KB |
Partially correct |
25 |
Partially correct |
60 ms |
8764 KB |
Partially correct |
26 |
Partially correct |
61 ms |
8752 KB |
Partially correct |
27 |
Partially correct |
70 ms |
8700 KB |
Partially correct |
28 |
Partially correct |
62 ms |
8728 KB |
Partially correct |
29 |
Partially correct |
59 ms |
8736 KB |
Partially correct |
30 |
Partially correct |
60 ms |
8732 KB |
Partially correct |
31 |
Partially correct |
62 ms |
8712 KB |
Partially correct |
32 |
Partially correct |
62 ms |
8724 KB |
Partially correct |
33 |
Partially correct |
56 ms |
8780 KB |
Partially correct |