# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
759894 |
2023-06-17T02:53:24 Z |
wenqi |
Archery (IOI09_archery) |
C++17 |
|
2000 ms |
8488 KB |
// trans rights
#include <bits/extc++.h>
using namespace std;
#define DIE assert(0);
int N, R;
int Q[400005], S;
int X[400005];
int cons[3];
int splash()
{
for (int i = 0; i < 3; i++)
if (cons[i])
return i;
DIE
}
int skilled()
{
memset(cons, 0, sizeof(cons));
int f = -1;
deque<pair<int, int>> dq;
for (int i = 0; i < 2 * N; i++)
dq.push_back({X[i] + 1, i / 2 + 1});
for (int r = 1; r <= 3 * N; r++)
{
while (r >= dq.front().second)
{
cons[dq.front().first]++;
dq.pop_front();
}
int a = splash();
cons[a]--;
int b = splash();
cons[b]--;
if (a > b)
swap(a, b);
dq.push_back({b, N + r});
cons[a]++;
if (r >= 2 * N and b == 1)
f = r;
}
assert(f != -1);
int diff = (R - f + N) % N;
return N - diff;
}
int cnt[200005][3];
int find_best(int p)
{
for (int i = 0; i <= 2; i++)
if (cnt[p][i])
return i;
DIE
}
int find_worst(int p)
{
for (int i = 2; i >= 0; i--)
if (cnt[p][i])
return i;
DIE
}
void zero(int p)
{
for (int i = 0; i < 3; i++)
cnt[p][i] = 0;
}
void mov(int i, int j, int (*f)(int))
{
int h = f(i);
cnt[i][h]--;
for (int k = 0; k < 3; k++)
cnt[j][k] += cnt[i][k];
zero(i);
cnt[i][h]++;
}
int washed()
{
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i < 2 * N; i++)
cnt[i / 2 + 1][X[i] + 1]++;
for (int k = 0; k < 3; k++)
{
mov(1, N, find_best);
for (int i = N; i > 1; i--)
mov(i, i - 1, find_worst);
}
for (int i = 1; i <= N; i++)
{
if (cnt[i][1])
return i;
}
DIE
}
void place(int p)
{
for (int i = 0; i < 2 * p - 1; i++)
X[i] = Q[i] > S ? 1 : -1;
X[2 * p - 1] = 0;
for (int i = 2 * p; i < 2 * N; i++)
X[i] = Q[i - 1] > S ? 1 : -1;
}
int solve(int (*f)())
{
pair<int, int> mn = {1e9, 0};
for (int i = 1; i <= N; i++)
{
place(i);
mn = min(mn, {f(), -i});
}
return -mn.second;
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> R;
R = (R - 2 * N) % N + 2 * N;
cin >> S;
for (int i = 0; i < 2 * N - 1; i++)
cin >> Q[i];
if (S == 1)
{
cout << N;
return 0;
}
if (S < N + 2)
{
cout << solve(skilled);
return 0;
}
cout << solve(washed);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
289 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
2632 KB |
Output is correct |
6 |
Correct |
9 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
324 KB |
Output is correct |
3 |
Correct |
107 ms |
384 KB |
Output is correct |
4 |
Execution timed out |
2083 ms |
984 KB |
Time limit exceeded |
5 |
Execution timed out |
2068 ms |
7956 KB |
Time limit exceeded |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Incorrect |
41 ms |
340 KB |
Output isn't correct |
8 |
Execution timed out |
2092 ms |
964 KB |
Time limit exceeded |
9 |
Execution timed out |
2089 ms |
1232 KB |
Time limit exceeded |
10 |
Incorrect |
59 ms |
340 KB |
Output isn't correct |
11 |
Execution timed out |
2086 ms |
1172 KB |
Time limit exceeded |
12 |
Correct |
331 ms |
444 KB |
Output is correct |
13 |
Execution timed out |
2092 ms |
5840 KB |
Time limit exceeded |
14 |
Correct |
1119 ms |
532 KB |
Output is correct |
15 |
Execution timed out |
2080 ms |
1808 KB |
Time limit exceeded |
16 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
17 |
Correct |
75 ms |
340 KB |
Output is correct |
18 |
Correct |
179 ms |
408 KB |
Output is correct |
19 |
Incorrect |
555 ms |
476 KB |
Output isn't correct |
20 |
Correct |
1135 ms |
536 KB |
Output is correct |
21 |
Execution timed out |
2078 ms |
1236 KB |
Time limit exceeded |
22 |
Execution timed out |
2063 ms |
1664 KB |
Time limit exceeded |
23 |
Execution timed out |
2077 ms |
8488 KB |
Time limit exceeded |
24 |
Correct |
10 ms |
2636 KB |
Output is correct |
25 |
Correct |
62 ms |
2692 KB |
Output is correct |
26 |
Correct |
710 ms |
2792 KB |
Output is correct |
27 |
Execution timed out |
2063 ms |
3148 KB |
Time limit exceeded |
28 |
Execution timed out |
2073 ms |
6228 KB |
Time limit exceeded |
29 |
Correct |
99 ms |
2644 KB |
Output is correct |
30 |
Correct |
691 ms |
2788 KB |
Output is correct |
31 |
Execution timed out |
2063 ms |
3156 KB |
Time limit exceeded |
32 |
Execution timed out |
2078 ms |
7624 KB |
Time limit exceeded |
33 |
Correct |
9 ms |
2644 KB |
Output is correct |
34 |
Correct |
9 ms |
2644 KB |
Output is correct |
35 |
Correct |
163 ms |
2716 KB |
Output is correct |
36 |
Correct |
213 ms |
2728 KB |
Output is correct |
37 |
Execution timed out |
2078 ms |
3012 KB |
Time limit exceeded |
38 |
Execution timed out |
2067 ms |
3284 KB |
Time limit exceeded |
39 |
Correct |
10 ms |
2632 KB |
Output is correct |
40 |
Correct |
58 ms |
2644 KB |
Output is correct |
41 |
Correct |
157 ms |
2712 KB |
Output is correct |
42 |
Correct |
195 ms |
2724 KB |
Output is correct |
43 |
Correct |
676 ms |
2796 KB |
Output is correct |
44 |
Execution timed out |
2080 ms |
2900 KB |
Time limit exceeded |
45 |
Execution timed out |
2048 ms |
3156 KB |
Time limit exceeded |
46 |
Execution timed out |
2075 ms |
3156 KB |
Time limit exceeded |
47 |
Execution timed out |
2076 ms |
8396 KB |
Time limit exceeded |