# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57533 |
2018-07-15T08:17:12 Z |
Crown |
Game (IOI13_game) |
C++14 |
|
4907 ms |
257024 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
const int maxr = 1e9+5;
const int maxc = 1e9+5;
long long gcd2(long long X, long long Y)
{
if(X == 0 || Y == 0)
{
return X+Y;
}
long long tmp;
while(X != Y && Y != 0)
{
tmp = X;
X = Y;
Y = tmp%Y;
}
return X;
}
struct layer2_node
{
layer2_node(int low, int high) : low(low), high(high), left(NULL), right(NULL), value(0LL) {}
int low, high;
layer2_node *left;
layer2_node *right;
ll value;
};
struct layer1_node
{
layer1_node() : left(NULL), right(NULL), l2(0, maxc) {}
layer1_node *left, *right;
layer2_node l2;
};
static layer1_node root;
static void update2(layer2_node* node, int Q, long long K)
{
int low = node->low;
int high = node->high;
int mid = (low+high)/2;
if(low == high)
{
node->value = K;
return;
}
layer2_node*& tgt = Q<=mid ? node->left : node->right;
if(tgt == NULL)
{
tgt = new layer2_node(Q, Q);
tgt->value = K;
}
else if(tgt->low <= Q && Q<= tgt->high)
{
update2(tgt, Q, K);
}
else
{
do
{
if(Q<= mid) high = mid;
else low = mid+1;
mid = (low+high)/2;
}
while((Q<= mid) == (tgt->low <= mid));
layer2_node* newnode = new layer2_node(low, high);
(tgt->low<= mid? newnode->left : newnode->right) = tgt;
tgt = newnode;
update2(newnode, Q, K);
}
node->value = gcd2(node->left? node->left->value: 0, node->right?node->right->value:0);
}
ll query2(layer2_node *nd, int A, int B)
{
if(nd == NULL || B< nd->low || A> nd->high) return 0;
else if(A<= nd->low && nd->high <= B) return nd->value;
return gcd2(query2(nd->left, A, B), query2(nd->right, A, B));
}
static void update1(layer1_node *node, int low, int high, int P, int Q, ll K)
{
int mid = (low+high)/2;
if(low == high)
{
update2(&node->l2, Q, K);
}
else
{
layer1_node*& newnode = P<= mid? node->left : node->right;
if(P<= mid) high = mid;
else low = mid+1;
if(newnode == NULL)
{
newnode = new layer1_node();
}
update1(newnode, low, high, P, Q, K);
K = gcd2(node->left?query2(&node->left->l2, Q, Q) : 0, node->right?query2(&node->right->l2, Q, Q) : 0);
update2(&node->l2, Q, K);
}
}
ll query1(layer1_node* nd, int low, int high, int A1, int B1, int A2, int B2)
{
if(nd == NULL || B1< low || high < A1)
{
return 0;
}
else if(A1<= low && high<= B1)
{
return query2(&nd->l2, A2, B2);
}
int mid = (low+high)/2;
return gcd2(query1(nd->left, low, mid, A1, B1, A2, B2), query1(nd->right, mid+1, high, A1, B1, A2, B2));
}
void init(int R, int C){}
void update(int P, int Q, long long K)
{
update1(&root, 0, maxr, P, Q, K);
}
long long calculate(int P, int Q, int U, int V)
{
return query1(&root, 0, maxr, P, U, Q, V);
}
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 |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
748 KB |
Output is correct |
3 |
Correct |
5 ms |
748 KB |
Output is correct |
4 |
Correct |
2 ms |
748 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
5 ms |
816 KB |
Output is correct |
7 |
Correct |
3 ms |
816 KB |
Output is correct |
8 |
Correct |
2 ms |
816 KB |
Output is correct |
9 |
Correct |
5 ms |
816 KB |
Output is correct |
10 |
Correct |
4 ms |
816 KB |
Output is correct |
11 |
Correct |
4 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
816 KB |
Output is correct |
2 |
Correct |
2 ms |
816 KB |
Output is correct |
3 |
Correct |
2 ms |
816 KB |
Output is correct |
4 |
Correct |
1119 ms |
35780 KB |
Output is correct |
5 |
Correct |
830 ms |
36008 KB |
Output is correct |
6 |
Correct |
1503 ms |
36008 KB |
Output is correct |
7 |
Correct |
1852 ms |
36008 KB |
Output is correct |
8 |
Correct |
913 ms |
36008 KB |
Output is correct |
9 |
Correct |
1783 ms |
36008 KB |
Output is correct |
10 |
Correct |
1533 ms |
36008 KB |
Output is correct |
11 |
Correct |
3 ms |
36008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
36008 KB |
Output is correct |
2 |
Correct |
5 ms |
36008 KB |
Output is correct |
3 |
Correct |
5 ms |
36008 KB |
Output is correct |
4 |
Correct |
2 ms |
36008 KB |
Output is correct |
5 |
Correct |
2 ms |
36008 KB |
Output is correct |
6 |
Correct |
4 ms |
36008 KB |
Output is correct |
7 |
Correct |
4 ms |
36008 KB |
Output is correct |
8 |
Correct |
3 ms |
36008 KB |
Output is correct |
9 |
Correct |
4 ms |
36008 KB |
Output is correct |
10 |
Correct |
3 ms |
36008 KB |
Output is correct |
11 |
Correct |
3 ms |
36008 KB |
Output is correct |
12 |
Correct |
1324 ms |
36008 KB |
Output is correct |
13 |
Correct |
2527 ms |
36008 KB |
Output is correct |
14 |
Correct |
512 ms |
36008 KB |
Output is correct |
15 |
Correct |
2787 ms |
36008 KB |
Output is correct |
16 |
Correct |
552 ms |
36008 KB |
Output is correct |
17 |
Correct |
1478 ms |
36008 KB |
Output is correct |
18 |
Correct |
2932 ms |
36008 KB |
Output is correct |
19 |
Correct |
2511 ms |
36008 KB |
Output is correct |
20 |
Correct |
2217 ms |
36008 KB |
Output is correct |
21 |
Correct |
3 ms |
36008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
36008 KB |
Output is correct |
2 |
Correct |
5 ms |
36008 KB |
Output is correct |
3 |
Correct |
5 ms |
36008 KB |
Output is correct |
4 |
Correct |
2 ms |
36008 KB |
Output is correct |
5 |
Correct |
2 ms |
36008 KB |
Output is correct |
6 |
Correct |
4 ms |
36008 KB |
Output is correct |
7 |
Correct |
3 ms |
36008 KB |
Output is correct |
8 |
Correct |
2 ms |
36008 KB |
Output is correct |
9 |
Correct |
5 ms |
36008 KB |
Output is correct |
10 |
Correct |
4 ms |
36008 KB |
Output is correct |
11 |
Correct |
4 ms |
36008 KB |
Output is correct |
12 |
Correct |
1033 ms |
36008 KB |
Output is correct |
13 |
Correct |
946 ms |
36152 KB |
Output is correct |
14 |
Correct |
1390 ms |
36152 KB |
Output is correct |
15 |
Correct |
1519 ms |
36152 KB |
Output is correct |
16 |
Correct |
864 ms |
36152 KB |
Output is correct |
17 |
Correct |
1390 ms |
36152 KB |
Output is correct |
18 |
Correct |
1354 ms |
36152 KB |
Output is correct |
19 |
Correct |
1496 ms |
36152 KB |
Output is correct |
20 |
Correct |
2800 ms |
36152 KB |
Output is correct |
21 |
Correct |
472 ms |
36152 KB |
Output is correct |
22 |
Correct |
3017 ms |
36152 KB |
Output is correct |
23 |
Correct |
638 ms |
36152 KB |
Output is correct |
24 |
Correct |
1846 ms |
36152 KB |
Output is correct |
25 |
Correct |
3600 ms |
36152 KB |
Output is correct |
26 |
Correct |
2702 ms |
36152 KB |
Output is correct |
27 |
Correct |
2477 ms |
36152 KB |
Output is correct |
28 |
Correct |
667 ms |
36504 KB |
Output is correct |
29 |
Correct |
2011 ms |
39228 KB |
Output is correct |
30 |
Correct |
4907 ms |
39228 KB |
Output is correct |
31 |
Correct |
4371 ms |
39228 KB |
Output is correct |
32 |
Correct |
485 ms |
39228 KB |
Output is correct |
33 |
Correct |
793 ms |
39228 KB |
Output is correct |
34 |
Correct |
1422 ms |
39228 KB |
Output is correct |
35 |
Correct |
2013 ms |
39228 KB |
Output is correct |
36 |
Correct |
3959 ms |
39228 KB |
Output is correct |
37 |
Correct |
2812 ms |
47260 KB |
Output is correct |
38 |
Correct |
2954 ms |
57340 KB |
Output is correct |
39 |
Correct |
2356 ms |
60776 KB |
Output is correct |
40 |
Correct |
4 ms |
60776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
60776 KB |
Output is correct |
2 |
Correct |
5 ms |
60776 KB |
Output is correct |
3 |
Correct |
4 ms |
60776 KB |
Output is correct |
4 |
Correct |
3 ms |
60776 KB |
Output is correct |
5 |
Correct |
4 ms |
60776 KB |
Output is correct |
6 |
Correct |
5 ms |
60776 KB |
Output is correct |
7 |
Correct |
3 ms |
60776 KB |
Output is correct |
8 |
Correct |
2 ms |
60776 KB |
Output is correct |
9 |
Correct |
4 ms |
60776 KB |
Output is correct |
10 |
Correct |
4 ms |
60776 KB |
Output is correct |
11 |
Correct |
3 ms |
60776 KB |
Output is correct |
12 |
Correct |
1170 ms |
71928 KB |
Output is correct |
13 |
Correct |
932 ms |
75928 KB |
Output is correct |
14 |
Correct |
1469 ms |
77860 KB |
Output is correct |
15 |
Correct |
1809 ms |
82072 KB |
Output is correct |
16 |
Correct |
1039 ms |
82072 KB |
Output is correct |
17 |
Correct |
1725 ms |
90932 KB |
Output is correct |
18 |
Correct |
1394 ms |
95252 KB |
Output is correct |
19 |
Correct |
1314 ms |
95252 KB |
Output is correct |
20 |
Correct |
2800 ms |
95252 KB |
Output is correct |
21 |
Correct |
455 ms |
95252 KB |
Output is correct |
22 |
Correct |
3074 ms |
95252 KB |
Output is correct |
23 |
Correct |
719 ms |
101552 KB |
Output is correct |
24 |
Correct |
1944 ms |
102304 KB |
Output is correct |
25 |
Correct |
3672 ms |
112344 KB |
Output is correct |
26 |
Correct |
3234 ms |
117660 KB |
Output is correct |
27 |
Correct |
2566 ms |
122444 KB |
Output is correct |
28 |
Correct |
790 ms |
151952 KB |
Output is correct |
29 |
Correct |
2012 ms |
164832 KB |
Output is correct |
30 |
Correct |
4881 ms |
164976 KB |
Output is correct |
31 |
Correct |
4452 ms |
164976 KB |
Output is correct |
32 |
Correct |
542 ms |
164976 KB |
Output is correct |
33 |
Correct |
855 ms |
164976 KB |
Output is correct |
34 |
Correct |
1233 ms |
200900 KB |
Output is correct |
35 |
Correct |
1821 ms |
200900 KB |
Output is correct |
36 |
Correct |
3890 ms |
221744 KB |
Output is correct |
37 |
Correct |
2840 ms |
232424 KB |
Output is correct |
38 |
Correct |
2764 ms |
242488 KB |
Output is correct |
39 |
Runtime error |
1103 ms |
257024 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
40 |
Halted |
0 ms |
0 KB |
- |