# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
261044 |
2020-08-11T10:29:32 Z |
SamAnd |
Game (IOI13_game) |
C++17 |
|
5851 ms |
256004 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int T = 22003 * 30 * 30 * 3;
long long gcd(long long X, long long Y) {
long long tmp;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
int R, C;
ll g[T];
int zy;
int uly[T], ury[T];
int zx;
int uy[T];
int ulx[T], urx[T];
void ubdy(int tlx, int trx, int tly, int try_, int x, int y, ll k, int posyl, int posyr, int posy)
{
if (tly == try_)
{
if (tlx == trx)
{
g[posy] = k;
return;
}
g[posy] = gcd(g[posyl], g[posyr]);
return;
}
int m = (tly + try_) / 2;
if (y <= m)
{
if (!uly[posy])
uly[posy] = ++zy;
ubdy(tlx, trx, tly, m, x, y, k, uly[posyl], uly[posyr], uly[posy]);
}
else
{
if (!ury[posy])
ury[posy] = ++zy;
ubdy(tlx, trx, m + 1, try_, x, y, k, ury[posyl], ury[posyr], ury[posy]);
}
g[posy] = gcd(g[uly[posy]], g[ury[posy]]);
}
void ubdx(int tlx, int trx, int x, int y, ll k, int posx)
{
if (tlx == trx)
{
if (!uy[posx])
uy[posx] = ++zy;
ubdy(tlx, trx, 0, C - 1, x, y, k, 0, 0, uy[posx]);
return;
}
int m = (tlx + trx) / 2;
if (x <= m)
{
if (!ulx[posx])
ulx[posx] = ++zx;
ubdx(tlx, m, x, y, k, ulx[posx]);
}
else
{
if (!urx[posx])
urx[posx] = ++zx;
ubdx(m + 1, trx, x, y, k, urx[posx]);
}
if (!uy[posx])
uy[posx] = ++zy;
ubdy(tlx, trx, 0, C - 1, x, y, k, uy[ulx[posx]], uy[urx[posx]], uy[posx]);
}
ll qryy(int tly, int try_, int ly, int ry, int posy)
{
if (ly > ry)
return 0;
if (posy == 0)
return 0;
if (tly == ly && try_ == ry)
return g[posy];
int m = (tly + try_) / 2;
return gcd(qryy(tly, m, ly, min(m, ry), uly[posy]),
qryy(m + 1, try_, max(m + 1, ly), ry, ury[posy]));
}
ll qryx(int tlx, int trx, int lx, int rx, int ly, int ry, int posx)
{
if (lx > rx)
return 0;
if (posx == 0)
return 0;
if (tlx == lx && trx == rx)
{
return qryy(0, C - 1, ly, ry, uy[posx]);
}
int m = (tlx + trx) / 2;
return gcd(qryx(tlx, m, lx, min(m, rx), ly, ry, ulx[posx]),
qryx(m + 1, trx, max(m + 1, lx), rx, ly, ry, urx[posx]));
}
void init(int R, int C)
{
::R = R;
::C = C;
++zx;
}
void update(int P, int Q, long long K)
{
ubdx(0, R - 1, P, Q, K, 1);
}
long long calculate(int P, int Q, int U, int V)
{
return qryx(0, R - 1, P, U, Q, V, 1);
}
Compilation message
grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
int res;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
617 ms |
9444 KB |
Output is correct |
5 |
Correct |
489 ms |
9720 KB |
Output is correct |
6 |
Correct |
512 ms |
6392 KB |
Output is correct |
7 |
Correct |
558 ms |
6140 KB |
Output is correct |
8 |
Correct |
398 ms |
5132 KB |
Output is correct |
9 |
Correct |
543 ms |
6264 KB |
Output is correct |
10 |
Correct |
500 ms |
5752 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1112 ms |
11048 KB |
Output is correct |
13 |
Correct |
1677 ms |
4472 KB |
Output is correct |
14 |
Correct |
353 ms |
1616 KB |
Output is correct |
15 |
Correct |
1963 ms |
5644 KB |
Output is correct |
16 |
Correct |
227 ms |
10488 KB |
Output is correct |
17 |
Correct |
844 ms |
7288 KB |
Output is correct |
18 |
Correct |
1447 ms |
10872 KB |
Output is correct |
19 |
Correct |
1257 ms |
11132 KB |
Output is correct |
20 |
Correct |
1133 ms |
10240 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
654 ms |
9408 KB |
Output is correct |
13 |
Correct |
481 ms |
9756 KB |
Output is correct |
14 |
Correct |
551 ms |
6572 KB |
Output is correct |
15 |
Correct |
583 ms |
6076 KB |
Output is correct |
16 |
Correct |
391 ms |
5092 KB |
Output is correct |
17 |
Correct |
551 ms |
6344 KB |
Output is correct |
18 |
Correct |
544 ms |
5844 KB |
Output is correct |
19 |
Correct |
1012 ms |
11272 KB |
Output is correct |
20 |
Correct |
1649 ms |
4396 KB |
Output is correct |
21 |
Correct |
356 ms |
1784 KB |
Output is correct |
22 |
Correct |
1967 ms |
5956 KB |
Output is correct |
23 |
Correct |
217 ms |
10360 KB |
Output is correct |
24 |
Correct |
803 ms |
7416 KB |
Output is correct |
25 |
Correct |
1608 ms |
10872 KB |
Output is correct |
26 |
Correct |
1372 ms |
11000 KB |
Output is correct |
27 |
Correct |
1169 ms |
10360 KB |
Output is correct |
28 |
Correct |
934 ms |
126328 KB |
Output is correct |
29 |
Correct |
2420 ms |
141688 KB |
Output is correct |
30 |
Correct |
5851 ms |
102688 KB |
Output is correct |
31 |
Correct |
5500 ms |
78768 KB |
Output is correct |
32 |
Correct |
702 ms |
1844 KB |
Output is correct |
33 |
Correct |
884 ms |
3156 KB |
Output is correct |
34 |
Correct |
512 ms |
138616 KB |
Output is correct |
35 |
Correct |
1737 ms |
71168 KB |
Output is correct |
36 |
Correct |
3432 ms |
139220 KB |
Output is correct |
37 |
Correct |
2619 ms |
139448 KB |
Output is correct |
38 |
Correct |
2775 ms |
138856 KB |
Output is correct |
39 |
Correct |
2469 ms |
107224 KB |
Output is correct |
40 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
625 ms |
9720 KB |
Output is correct |
13 |
Correct |
464 ms |
9720 KB |
Output is correct |
14 |
Correct |
532 ms |
6580 KB |
Output is correct |
15 |
Correct |
569 ms |
6264 KB |
Output is correct |
16 |
Correct |
419 ms |
5468 KB |
Output is correct |
17 |
Correct |
559 ms |
6540 KB |
Output is correct |
18 |
Correct |
503 ms |
6136 KB |
Output is correct |
19 |
Correct |
1037 ms |
11336 KB |
Output is correct |
20 |
Correct |
1658 ms |
4592 KB |
Output is correct |
21 |
Correct |
363 ms |
1784 KB |
Output is correct |
22 |
Correct |
1980 ms |
5884 KB |
Output is correct |
23 |
Correct |
220 ms |
10488 KB |
Output is correct |
24 |
Correct |
835 ms |
7608 KB |
Output is correct |
25 |
Correct |
1698 ms |
10904 KB |
Output is correct |
26 |
Correct |
1301 ms |
11128 KB |
Output is correct |
27 |
Correct |
1164 ms |
10492 KB |
Output is correct |
28 |
Correct |
880 ms |
126456 KB |
Output is correct |
29 |
Correct |
2401 ms |
141752 KB |
Output is correct |
30 |
Correct |
5793 ms |
102772 KB |
Output is correct |
31 |
Correct |
5409 ms |
78960 KB |
Output is correct |
32 |
Correct |
677 ms |
1888 KB |
Output is correct |
33 |
Correct |
824 ms |
3064 KB |
Output is correct |
34 |
Correct |
474 ms |
138332 KB |
Output is correct |
35 |
Correct |
1822 ms |
71160 KB |
Output is correct |
36 |
Correct |
3433 ms |
139080 KB |
Output is correct |
37 |
Correct |
2715 ms |
139000 KB |
Output is correct |
38 |
Correct |
2776 ms |
138452 KB |
Output is correct |
39 |
Runtime error |
1268 ms |
256004 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
40 |
Halted |
0 ms |
0 KB |
- |