結果
問題 | No.1014 competitive fighting |
ユーザー |
![]() |
提出日時 | 2020-03-20 22:17:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 8,348 bytes |
コンパイル時間 | 3,482 ms |
コンパイル使用メモリ | 225,972 KB |
最終ジャッジ日時 | 2025-01-09 08:38:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 23 WA * 28 |
コンパイルメッセージ
In function ‘S min_L(S, T) [with S = long long int; T = long long int]’, inlined from ‘int main()’ at main.cpp:370:26: main.cpp:7:14: warning: ‘res’ may be used uninitialized [-Wmaybe-uninitialized] 7 | return a<=b?a:b; | ~~~~^~~~ main.cpp: In function ‘int main()’: main.cpp:251:7: note: ‘res’ was declared here 251 | T res; | ^~~ In function ‘S min_L(S, T) [with S = long long int; T = long long int]’, inlined from ‘int main()’ at main.cpp:370:26: main.cpp:7:14: warning: ‘res’ may be used uninitialized [-Wmaybe-uninitialized] 7 | return a<=b?a:b; | ~~~~^~~~ main.cpp: In function ‘int main()’: main.cpp:251:7: note: ‘res’ was declared here 251 | T res; | ^~~ main.cpp:367:13: warning: ‘res’ may be used uninitialized [-Wmaybe-uninitialized] 367 | tmp = B[i] - t.getMinVal(0,nx[i]+1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:251:7: note: ‘res’ was declared here 251 | T res; | ^~~
ソースコード
#pragma GCC optimize ("Ofast")#include<bits/stdc++.h>using namespace std;void *wmem;char memarr[96000000];template<class S, class T> inline S min_L(S a,T b){return a<=b?a:b;}template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};(*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );(*arr)=(T*)(*mem);(*mem)=((*arr)+x);}template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){sort(a, a+N);}template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){int i;pair<T1, T2> *arr;walloc1d(&arr, N, &mem);for(i=(0);i<(N);i++){arr[i].first = a[i];arr[i].second = b[i];}sort(arr, arr+N);for(i=(0);i<(N);i++){a[i] = arr[i].first;b[i] = arr[i].second;}}template<class T1, class T2, class T3> void sortA_L(int N, T1 a[], T2 b[], T3 c[], void *mem = wmem){int i;pair<T1, pair<T2, T3> > *arr;walloc1d(&arr, N, &mem);for(i=(0);i<(N);i++){arr[i].first = a[i];arr[i].second.first = b[i];arr[i].second.second = c[i];}sort(arr, arr+N);for(i=(0);i<(N);i++){a[i] = arr[i].first;b[i] = arr[i].second.first;c[i] = arr[i].second.second;}}template<class T1, class T2, class T3, class T4> void sortA_L(int N, T1 a[], T2 b[], T3 c[], T4 d[], void *mem = wmem){int i;pair<pair<T1, T2>, pair<T3, T4> > *arr;walloc1d(&arr, N, &mem);for(i=(0);i<(N);i++){arr[i].first.first = a[i];arr[i].first.second = b[i];arr[i].second.first = c[i];arr[i].second.second = d[i];}sort(arr, arr+N);for(i=(0);i<(N);i++){a[i] = arr[i].first.first;b[i] = arr[i].first.second;c[i] = arr[i].second.first;d[i] = arr[i].second.second;}}inline int my_getchar_unlocked(){static char buf[1048576];static int s = 1048576;static int e = 1048576;if(s == e && e == 1048576){e = fread_unlocked(buf, 1, 1048576, stdin);s = 0;}if(s == e){return EOF;}return buf[s++];}inline void rd(int &x){int k;int m=0;x=0;for(;;){k = my_getchar_unlocked();if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){k = my_getchar_unlocked();if(k<'0'||k>'9'){break;}x=x*10+k-'0';}if(m){x=-x;}}inline void rd(long long &x){int k;int m=0;x=0;for(;;){k = my_getchar_unlocked();if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){k = my_getchar_unlocked();if(k<'0'||k>'9'){break;}x=x*10+k-'0';}if(m){x=-x;}}struct MY_WRITER{char buf[1048576];int s;int e;MY_WRITER(){s = 0;e = 1048576;}~MY_WRITER(){if(s){fwrite_unlocked(buf, 1, s, stdout);}}};MY_WRITER MY_WRITER_VAR;void my_putchar_unlocked(int a){if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);MY_WRITER_VAR.s = 0;}MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;}inline void wt_L(char a){my_putchar_unlocked(a);}inline void wt_L(long long x){int s=0;int m=0;char f[20];if(x<0){m=1;x=-x;}while(x){f[s++]=x%10;x/=10;}if(!s){f[s++]=0;}if(m){my_putchar_unlocked('-');}while(s--){my_putchar_unlocked(f[s]+'0');}}inline void wt_L(const char c[]){int i=0;for(i=0;c[i]!='\0';i++){my_putchar_unlocked(c[i]);}}template<class T> struct segtree_Point_Minval{int N;int logN;T *mn;void malloc(int maxN, int once = 0){int i;for(i=1;i<maxN;i*=2){;}mn = new T[2*i];if(once){setN(maxN);}}void walloc(int maxN, int once = 0, void **mem = &wmem){int i;for(i=1;i<maxN;i*=2){;}walloc1d(&mn, 2*i, mem);if(once){setN(maxN);}}void free(void){delete [] mn;}T& operator[](int i){return mn[N+i];}void setN(int n, int zerofill = 1, int dobuild = 1){int i;for(i=1,logN=0;i<n;i*=2,logN++){;}N = i;if(zerofill){for(i=(0);i<(N);i++){mn[N+i] = 0;}}if(dobuild){build();}}void build(void){int i;for(i=N-1;i;i--){mn[i] =min_L(mn[2*i], mn[2*i+1]);}}inline void build(int a){while(a > 1){a /= 2;mn[a] =min_L(mn[2*a], mn[2*a+1]);}}inline void change(int a, T val){mn[a+N] = val;build(a+N);}inline void add(int a, T val){mn[a+N] += val;build(a+N);}inline T getMinVal(int a, int b){T res;T tmp;int fga = 0;int fgb = 0;a += N;b += N;while(a < b){if(a%2){if(fga){res =min_L(res, mn[a]);}else{res = mn[a];fga = 1;}a++;}if(b%2){b--;if(fgb){tmp =min_L(mn[b], tmp);}else{tmp = mn[b];fgb = 1;}}a /= 2;b /= 2;}if(fga==1 && fgb==0){return res;}if(fga==0 && fgb==1){return tmp;}if(fga==1 && fgb==1){res =min_L(res, tmp);return res;}return res;}};int N;long long A[100000];long long B[100000];long long C[100000];int ind[100000];int nx[100000];int val[100000];int nxind[100000];long long res[100000];int main(){int i, loop;wmem = memarr;long long tmp;segtree_Point_Minval<long long> t;rd(N);{int Lj4PdHRW;for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){rd(A[Lj4PdHRW]);rd(B[Lj4PdHRW]);rd(C[Lj4PdHRW]);}}for(i=(0);i<(N);i++){ind[i] = i;}sortA_L(N,A,B,C,ind);for(i=(0);i<(N);i++){int xr20shxY;int WYIGIcGE;int t_ynMSdg;xr20shxY = -1;WYIGIcGE = N-1;while(xr20shxY < WYIGIcGE){if((xr20shxY + WYIGIcGE)%2==0){t_ynMSdg = (xr20shxY + WYIGIcGE) / 2;}else{t_ynMSdg = (xr20shxY + WYIGIcGE + 1) / 2;}if(A[t_ynMSdg] <= B[i]-C[i]){xr20shxY = t_ynMSdg;}else{WYIGIcGE = t_ynMSdg - 1;}}nx[i] =WYIGIcGE;}for(i=(0);i<(N);i++){if(nx[i]==i){nx[i]--;}}for(i=(0);i<(N);i++){{auto APIVbQlN = (nx[i]);auto YREPHmFM = ( i);val[i] = APIVbQlN;nxind[i] = YREPHmFM;}}sortA_L(N, val, nxind);t.walloc(N,1);for(loop=(0);loop<(4);loop++){int ZIeRIny5;for(ZIeRIny5=(0);ZIeRIny5<(N);ZIeRIny5++){auto &i = nxind[ZIeRIny5];if(nx[i]==-1){tmp = B[i];}else if(nx[i] < i){tmp = B[i] - t.getMinVal(0,nx[i]+1);}else{tmp = B[i] -min_L(t.getMinVal(0,i), t.getMinVal(i+1,nx[i]+1));}if(tmp >= 4611686016279904256LL){tmp = 4611686016279904256LL;}if(res[ind[i]] < tmp){res[ind[i]] = tmp;t.change(i, -tmp);}}}for(i=(0);i<(N);i++){if(res[i]==4611686016279904256LL){wt_L("BAN");wt_L('\n');}else{wt_L(res[i]);wt_L('\n');}}return 0;}// cLay varsion 20200317-1// --- original code ---// int N; ll A[1d5], B[1d5], C[1d5];// int ind[1d5];//// int nx[1d5], val[1d5], nxind[1d5];// ll res[1d5];//// {// ll tmp;// segtree_Point_Minval<ll> t;// rd(N,(A,B,C)(N));// rep(i,N) ind[i] = i;// sortA(N,A,B,C,ind);//// rep(i,N) nx[i] = bsearch_max[int,x,-1,N-1](A[x] <= B[i]-C[i]);// rep(i,N) if(nx[i]==i) nx[i]--;// rep(i,N) (val[i], nxind[i]) = (nx[i], i);// sortA(N, val, nxind);//// t.walloc(N,1);// rep(loop,4) rep[nxind](i,N){// if(nx[i]==-1){// tmp = B[i];// } else if(nx[i] < i){// tmp = B[i] - t.getMinVal(0,nx[i]+1);// } else {// tmp = B[i] - min(t.getMinVal(0,i), t.getMinVal(i+1,nx[i]+1));// }// if(tmp >= ll_inf) tmp = ll_inf;// if(res[ind[i]] < tmp){// // if(loop==3) tmp = ll_inf;// res[ind[i]] = tmp;// t.change(i, -tmp);// }// }//// rep(i,N) wt(if[res[i]==ll_inf, "BAN", res[i]]);// }