# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
62892 |
2018-07-30T17:24:04 Z |
mhnd |
Game (IOI13_game) |
C++14 |
|
7940 ms |
257024 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5+50;
const ll oo = 1e18;
const ll mod = 1e9+7;
ll seg2[11][2*N+123];
int c,type,ro,up,dw;
struct node{
int sub[4*2010] = {0};
node(){
memset(sub,0,sizeof(sub));
}
}seg[4*2010];
long long gcd2(long long X, long long Y) {
long long tmp;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
ll l,r,val,cur,in;
void update2(int n,int s,int e){
if(s > cur || e < cur)return;
if(s == e){
seg[in].sub[n] = val;
return;
}
update2(n*2,s,(s+e)/2);
update2(n*2+1,(s+e)/2+1,e);
seg[in].sub[n] = gcd2(seg[in].sub[n*2],seg[in].sub[n*2+1]);
}
void merge(int n,int s,int e){
if(s == e){
seg[in].sub[n] = gcd2(seg[in*2].sub[n],seg[in*2+1].sub[n]);
return;
}
merge(n*2,s,(s+e)/2);
merge(n*2+1,(s+e)/2+1,e);
seg[in].sub[n] = gcd2(seg[in].sub[n*2],seg[in].sub[n*2+1]);
}
void update1(int n,int s,int e){
if(s > r || e < l)return;
if(s == e){
if(type){
in = n;
update2(1,1,ro);
}else seg2[cur][n] = val;
return;
}
update1(n*2,s,(s+e)/2);
update1(n*2+1,(s+e)/2+1,e);
if(type){
in = n;
merge(1,1,ro);
}else seg2[cur][n] = gcd2(seg2[cur][n*2],seg2[cur][n*2+1]);
}
int l1,r1;
ll get1(int n,int s,int e){
if(s > r1 || e < l1)return 0;
if(s >= l1 && e <= r1)return seg[in].sub[n];
return gcd2(get1(n*2,s,(s+e)/2),get1(n*2+1,(s+e)/2+1,e));
}
ll get(int n,int s,int e){
if(s > r || e < l)return 0;
if(s >= l && e <= r){
if(type){
in = n;
l1 = up;
r1 = dw;
//cout << in << ' ' << up << ' ' << dw << endl;
return get1(1,1,ro);
}
else return seg2[cur][n];
}
return gcd2(get(n*2,s,(s+e)/2),get(n*2+1,(s+e)/2+1,e));
}
void init(int R, int C) {
type = R>10;
c=C;
ro=R;
}
void update(int P, int Q, long long K) {
Q++;
P++;
l = r = Q;
val = K;
cur = P;
update1(1,1,c);
//up = dw = 1;
//cout << get(1,1,c) << endl;
}
long long calculate(int P, int Q, int U, int V) {
l = Q+1;
r = V+1;
ll ans = 0;
up = P+1;
dw = U+1;
if(type)ans = get(1,1,c);
else{
for(int i=P+1;i<=U+1;i++){
cur = i;
ans = gcd2(ans,get(1,1,c));
}
}
return ans;
}
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 |
199 ms |
253368 KB |
Output is correct |
2 |
Incorrect |
191 ms |
253412 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
188 ms |
253412 KB |
Output is correct |
2 |
Correct |
195 ms |
253412 KB |
Output is correct |
3 |
Correct |
209 ms |
253412 KB |
Output is correct |
4 |
Runtime error |
7940 ms |
257024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
240 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. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
235 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. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
215 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. |
2 |
Halted |
0 ms |
0 KB |
- |