답안 #68961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68961 2018-08-19T11:19:01 Z MKopchev 게임 (IOI13_game) C++14
37 / 100
13000 ms 28980 KB
#include<bits/stdc++.h>
#include "game.h"
using namespace std;
vector< vector<long long> > tree;
long long my_gcd(long long a,long long b)
{
    if(a==0||b==0)return a+b;
    long long r=a%b;
    while(r)
    {
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int r,c;
void init(int R, int C)
{
    r=R;
    c=C;
    int mx=1;
    while(mx<C)mx=mx*2;
    mx=mx*2+5;
    vector<long long> help={};
    for(int j=0;j<mx;j++)help.push_back(0);
    for(int i=0;i<R;i++)
        {
        tree.push_back(help);
        }
}
void my_update(int ind,int node,int l,int r,int pos,long long val)
{
    if(l==r)
    {
        tree[ind][node]=val;
        return;
    }
    int av=(l+r)/2;
    if(pos<=av)my_update(ind,node*2,l,av,pos,val);
    else my_update(ind,node*2+1,av+1,r,pos,val);
    tree[ind][node]=my_gcd(tree[ind][node*2],tree[ind][node*2+1]);
}
void update(int P, int Q, long long K)
{
    my_update(P,1,0,c-1,Q,K);
}
long long my_query(int ind,int node,int l,int r,int lq,int rq)
{
    if(tree[ind][node]==0)return tree[ind][node];
    if(l==lq&&r==rq)return tree[ind][node];
    int av=(l+r)/2;
    long long ans=0;
    if(lq<=av)ans=my_gcd(ans,my_query(ind,node*2,l,av,lq,min(av,rq)));
    if(av<rq)ans=my_gcd(ans,my_query(ind,node*2+1,av+1,r,max(av+1,lq),rq));
    return ans;
}
long long calculate(int P, int Q, int U, int V)
{
    long long ans=0;
    for(int i=P;i<=U;i++)
        ans=my_gcd(ans,my_query(i,1,0,c-1,Q,V));
    return ans;
}
/*
int main()
{
init(2,3);
update(0,0,20);
update(0,2,15);
update(1,1,12);
cout<<calculate(0,0,0,2)<<endl;//5
cout<<calculate(0,0,1,1)<<endl;//4
update(0,1,6);
update(1,1,14);
cout<<calculate(0,0,0,2)<<endl;//1
cout<<calculate(0,0,1,1)<<endl;//2

}
*/

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;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 612 KB Output is correct
3 Correct 3 ms 688 KB Output is correct
4 Correct 2 ms 688 KB Output is correct
5 Correct 2 ms 712 KB Output is correct
6 Correct 2 ms 856 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 3 ms 856 KB Output is correct
11 Correct 3 ms 856 KB Output is correct
12 Correct 2 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 856 KB Output is correct
2 Correct 3 ms 856 KB Output is correct
3 Correct 2 ms 856 KB Output is correct
4 Correct 1189 ms 25188 KB Output is correct
5 Correct 878 ms 25444 KB Output is correct
6 Correct 845 ms 25444 KB Output is correct
7 Correct 913 ms 25444 KB Output is correct
8 Correct 575 ms 25444 KB Output is correct
9 Correct 905 ms 25444 KB Output is correct
10 Correct 858 ms 25444 KB Output is correct
11 Correct 3 ms 25444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 25444 KB Output is correct
2 Correct 3 ms 25444 KB Output is correct
3 Correct 4 ms 25444 KB Output is correct
4 Correct 3 ms 25444 KB Output is correct
5 Correct 3 ms 25444 KB Output is correct
6 Correct 3 ms 25444 KB Output is correct
7 Correct 3 ms 25444 KB Output is correct
8 Correct 2 ms 25444 KB Output is correct
9 Correct 3 ms 25444 KB Output is correct
10 Correct 3 ms 25444 KB Output is correct
11 Correct 3 ms 25444 KB Output is correct
12 Execution timed out 13058 ms 25444 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 25444 KB Output is correct
2 Correct 3 ms 25444 KB Output is correct
3 Correct 2 ms 25444 KB Output is correct
4 Correct 2 ms 25444 KB Output is correct
5 Correct 4 ms 25444 KB Output is correct
6 Correct 3 ms 25444 KB Output is correct
7 Correct 2 ms 25444 KB Output is correct
8 Correct 3 ms 25444 KB Output is correct
9 Correct 3 ms 25444 KB Output is correct
10 Correct 3 ms 25444 KB Output is correct
11 Correct 2 ms 25444 KB Output is correct
12 Correct 1194 ms 27004 KB Output is correct
13 Correct 817 ms 27384 KB Output is correct
14 Correct 861 ms 27384 KB Output is correct
15 Correct 945 ms 27384 KB Output is correct
16 Correct 706 ms 27384 KB Output is correct
17 Correct 864 ms 27384 KB Output is correct
18 Correct 783 ms 27384 KB Output is correct
19 Execution timed out 13038 ms 27384 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 27384 KB Output is correct
2 Correct 3 ms 27384 KB Output is correct
3 Correct 2 ms 27384 KB Output is correct
4 Correct 2 ms 27384 KB Output is correct
5 Correct 2 ms 27384 KB Output is correct
6 Correct 3 ms 27384 KB Output is correct
7 Correct 2 ms 27384 KB Output is correct
8 Correct 3 ms 27384 KB Output is correct
9 Correct 3 ms 27384 KB Output is correct
10 Correct 3 ms 27384 KB Output is correct
11 Correct 3 ms 27384 KB Output is correct
12 Correct 1123 ms 28744 KB Output is correct
13 Correct 872 ms 28980 KB Output is correct
14 Correct 883 ms 28980 KB Output is correct
15 Correct 967 ms 28980 KB Output is correct
16 Correct 618 ms 28980 KB Output is correct
17 Correct 875 ms 28980 KB Output is correct
18 Correct 772 ms 28980 KB Output is correct
19 Execution timed out 13042 ms 28980 KB Time limit exceeded
20 Halted 0 ms 0 KB -