#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int cnt = 0;
pair<int, int> pos[100001];
set<pair<int, int>> active;
inline ll sq(int x) { return ll(x) * ll(x); }
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
while (m--) {
char c;
cin >> c;
if (c == 'E') {
cnt++;
if (!active.size()) pos[cnt] = {1, 1};
else {
pair<ll, pair<int, int>> best = {-1, {0, 0}};
for (int i = 1; i <= n; i++) {
for (int j = 1; j < 3; j++) {
ll dist = LLONG_MAX;
for (pair<int, int> k : active) {
dist = min(dist, sq(k.first - i) + sq(k.second - j));
}
if (dist > best.first) best = {dist, {i, j}};
}
}
pos[cnt] = best.second;
}
active.insert(pos[cnt]);
cout << pos[cnt].first << ' ' << pos[cnt].second << '\n';
} else {
int i;
cin >> i;
active.erase(pos[i]);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1043 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1096 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |