# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
30005 |
2017-07-21T11:56:59 Z |
inqr |
Game (IOI13_game) |
C++14 |
|
13000 ms |
80184 KB |
#include "game.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define DB printf("debug\n");
using namespace std;
long long g[100][100000];
int r,c,q;
long long kok[10][320];
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;
}
void init(int R, int C){
r=R;c=C,q=(int)(sqrt(C));
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
kok[i][j/q]=gcd2(kok[i][j/q],g[i][j]);
}
}
}
void update(int P, int Q, long long K){
if(kok[P][Q/q]==g[P][Q]){
g[P][Q]=K;
kok[P][Q/q]=0;
for(int i=Q/q*q;i<Q/q*q+q;i++){
kok[P][Q/q]=gcd2(kok[P][Q/q],g[P][i]);
}
}
g[P][Q]=K;
kok[P][Q/q]=gcd2(kok[P][Q/q],g[P][Q]);
}
long long calculate2(int P, int Q, int U, int V) {
long long ans=g[P][Q];
for(int i=P;i<=U;i++){
for(int j=Q;j<=V;j++){
ans=gcd2(ans,g[i][j]);
}
}
return ans;
}
long long calculate3(int P, int Q, int U, int V) {
long long ans=g[P][Q];
for(int i=P;i<=U;i++){
for(int j=Q;j<=V;j++){
if(Q<=j-q && j+q<=V){
ans=gcd2(ans,kok[i][j/q]);
j+=q-1;
}
else ans=gcd2(ans,g[i][j]);
}
}
return ans;
}
long long calculate(int P, int Q, int U, int V) {
if(r<=100 and c<=100)return calculate2(P,Q,U,V);
else return calculate3(P,Q,U,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 |
0 ms |
80184 KB |
Output is correct |
2 |
Correct |
0 ms |
80184 KB |
Output is correct |
3 |
Correct |
0 ms |
80184 KB |
Output is correct |
4 |
Correct |
0 ms |
80184 KB |
Output is correct |
5 |
Correct |
0 ms |
80184 KB |
Output is correct |
6 |
Correct |
0 ms |
80184 KB |
Output is correct |
7 |
Correct |
0 ms |
80184 KB |
Output is correct |
8 |
Correct |
0 ms |
80184 KB |
Output is correct |
9 |
Correct |
0 ms |
80184 KB |
Output is correct |
10 |
Correct |
0 ms |
80184 KB |
Output is correct |
11 |
Correct |
0 ms |
80184 KB |
Output is correct |
12 |
Correct |
0 ms |
80184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
80184 KB |
Output is correct |
2 |
Correct |
0 ms |
80184 KB |
Output is correct |
3 |
Correct |
0 ms |
80184 KB |
Output is correct |
4 |
Execution timed out |
13000 ms |
80184 KB |
Execution timed out |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
80184 KB |
Output is correct |
2 |
Correct |
0 ms |
80184 KB |
Output is correct |
3 |
Correct |
0 ms |
80184 KB |
Output is correct |
4 |
Correct |
0 ms |
80184 KB |
Output is correct |
5 |
Correct |
0 ms |
80184 KB |
Output is correct |
6 |
Correct |
0 ms |
80184 KB |
Output is correct |
7 |
Correct |
0 ms |
80184 KB |
Output is correct |
8 |
Correct |
0 ms |
80184 KB |
Output is correct |
9 |
Correct |
0 ms |
80184 KB |
Output is correct |
10 |
Correct |
0 ms |
80184 KB |
Output is correct |
11 |
Correct |
0 ms |
80184 KB |
Output is correct |
12 |
Runtime error |
0 ms |
80184 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
80184 KB |
Output is correct |
2 |
Correct |
0 ms |
80184 KB |
Output is correct |
3 |
Correct |
0 ms |
80184 KB |
Output is correct |
4 |
Correct |
0 ms |
80184 KB |
Output is correct |
5 |
Correct |
0 ms |
80184 KB |
Output is correct |
6 |
Correct |
0 ms |
80184 KB |
Output is correct |
7 |
Correct |
0 ms |
80184 KB |
Output is correct |
8 |
Correct |
0 ms |
80184 KB |
Output is correct |
9 |
Correct |
0 ms |
80184 KB |
Output is correct |
10 |
Correct |
0 ms |
80184 KB |
Output is correct |
11 |
Correct |
0 ms |
80184 KB |
Output is correct |
12 |
Execution timed out |
13000 ms |
80184 KB |
Execution timed out |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
80184 KB |
Output is correct |
2 |
Correct |
0 ms |
80184 KB |
Output is correct |
3 |
Correct |
0 ms |
80184 KB |
Output is correct |
4 |
Correct |
0 ms |
80184 KB |
Output is correct |
5 |
Correct |
0 ms |
80184 KB |
Output is correct |
6 |
Correct |
0 ms |
80184 KB |
Output is correct |
7 |
Correct |
0 ms |
80184 KB |
Output is correct |
8 |
Correct |
0 ms |
80184 KB |
Output is correct |
9 |
Correct |
0 ms |
80184 KB |
Output is correct |
10 |
Correct |
0 ms |
80184 KB |
Output is correct |
11 |
Correct |
0 ms |
80184 KB |
Output is correct |
12 |
Execution timed out |
13000 ms |
80184 KB |
Execution timed out |
13 |
Halted |
0 ms |
0 KB |
- |