제출 #31236

#제출 시각아이디문제언어결과실행 시간메모리
31236pasa3232마상시합 토너먼트 (IOI12_tournament)C++14
100 / 100
106 ms6288 KiB
#include<bits/stdc++.h> #define inbuf_len 1 << 16 #define outbuf_len 1 << 16 using namespace std; int n, m, r, ans, M=-1, A[100010], data[100010], sum[100010], tree[400010], check[100010]; void make_tree(int node, int s, int e){ if(s==e){ tree[node]=1; return; } int m=s+e>>1; make_tree(node*2, s, m); make_tree(node*2+1, m+1, e); tree[node]=tree[node*2]+tree[node*2+1]; } void update(int node, int s, int e, int s1, int e1){ if(e<s1||e1<s) return; if(s1<=s&&e<=e1){ tree[node]=0; return; } int m=s+e>>1; update(node*2, s, m, s1, e1); update(node*2+1, m+1, e, s1, e1); tree[node]=tree[node*2]+tree[node*2+1]; } int gets(int node, int s, int e, int val){ int m=s+e>>1; if(tree[node]==e-s+1&&tree[node]==val) return e; if(tree[node*2]>=val) return gets(node*2, s, m, val); return gets(node*2+1, m+1, e, val-tree[node*2]); } int gete(int node, int s, int e, int val){ int m=s+e>>1; if(tree[node]==val) return e; if(s==e) return -1; if(tree[node*2]>val) return gete(node*2, s, m, val); if(tree[node*2]<val) return gete(node*2+1, m+1, e, val-tree[node*2]); if(tree[node*2]==val) return max(gete(node*2, s, m, val), gete(node*2+1, m+1, e, val-tree[node*2])); } int GetBestPosition(int N, int C, int R, int *K, int *S, int *E){ n=N, m=C, r=R; for(int i=0; i<n; i++){ if(K[i]>r) data[i]=1; sum[i]=data[i]; if(i>0) sum[i]+=sum[i-1]; } make_tree(1, 0, n-1); // for(int i=1; i<=9; i++) printf("%d ", tree[i]); puts(""); for(int i=0; i<m; i++){ int x=S[i], y=E[i], s, e, ch=1; s=gets(1, 0, n-1, x+1); e=gete(1, 0, n-1, y+1); update(1, 0, n-1, s+1, e); if(sum[e-1]-(s-1>=0?sum[s-1]:0)>=1) ch=0; A[s]+=ch, A[e+1]+=-ch; // printf("%d %d %d %d %d\n", x, y, s, e, ch); } for(int i=0; i<=n; i++){ if(i>0) A[i]+=A[i-1]; if(M<A[i]) M=A[i], ans=i; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

tournament.cpp: In function 'void make_tree(int, int, int)':
tournament.cpp:13:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m=s+e>>1;
            ^
tournament.cpp: In function 'void update(int, int, int, int, int)':
tournament.cpp:25:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m=s+e>>1;
            ^
tournament.cpp: In function 'int gets(int, int, int, int)':
tournament.cpp:32:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m=s+e>>1;
            ^
tournament.cpp: In function 'int gete(int, int, int, int)':
tournament.cpp:39:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m=s+e>>1;
            ^
tournament.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...