結果
問題 | No.318 学学学学学 |
ユーザー | LayCurse |
提出日時 | 2015-12-11 00:09:10 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 5,004 bytes |
コンパイル時間 | 2,112 ms |
コンパイル使用メモリ | 165,868 KB |
実行使用メモリ | 9,160 KB |
最終ジャッジ日時 | 2024-06-22 14:19:39 |
合計ジャッジ時間 | 4,098 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,816 KB |
testcase_01 | AC | 6 ms
6,944 KB |
testcase_02 | AC | 7 ms
6,940 KB |
testcase_03 | AC | 5 ms
6,944 KB |
testcase_04 | AC | 6 ms
6,940 KB |
testcase_05 | AC | 30 ms
7,876 KB |
testcase_06 | AC | 40 ms
8,004 KB |
testcase_07 | AC | 32 ms
7,492 KB |
testcase_08 | AC | 29 ms
9,036 KB |
testcase_09 | AC | 26 ms
8,008 KB |
testcase_10 | AC | 22 ms
7,364 KB |
testcase_11 | AC | 32 ms
8,904 KB |
testcase_12 | AC | 27 ms
9,036 KB |
testcase_13 | AC | 26 ms
8,004 KB |
testcase_14 | AC | 23 ms
8,776 KB |
testcase_15 | AC | 22 ms
7,368 KB |
testcase_16 | AC | 17 ms
7,496 KB |
testcase_17 | AC | 27 ms
9,160 KB |
testcase_18 | AC | 18 ms
8,904 KB |
testcase_19 | AC | 27 ms
7,872 KB |
testcase_20 | AC | 19 ms
9,032 KB |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,944 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | AC | 1 ms
6,940 KB |
testcase_27 | AC | 1 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function ‘void reader(double*)’: main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | void reader(double *x){scanf("%lf",x);} | ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) #define ll long long #define ull unsigned ll void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);} template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,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)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template<class T> void writerLn(T x){writer(x,'\n');} template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} char memarr[17000000]; void *mem = memarr; #define MD 1000000007 template<class T> int coordinateCompress(int n, T arr[], int res[], void *mem){int i,k=0;pair<T,int>*r=(pair<T,int>*)mem;rep(i,n)r[i].first=arr[i],r[i].second=i;sort(r,r+n);if(res!=NULL){rep(i,n){if(i&&r[i].first!=r[i-1].first)k++;res[r[i].second]=k;}}else{rep(i,n){if(i&&r[i].first!=r[i-1].first)k++;arr[r[i].second]=k;}}return k+1;} template<class T> int coordinateCompress(int n1, T arr1[], int n2, T arr2[], int res1[], int res2[], void *mem){int i,k=0;pair<T,int>*r =(pair<T,int>*)mem;rep(i,n1)r[i].first=arr1[i],r[i].second=i;rep(i,n2)r[n1+i].first=arr2[i],r[n1+i].second=n1+i;sort(r,r+n1+n2);rep(i,n1+n2){if(i&&r[i].first!=r[i-1].first) k++;if(r[i].second<n1){if(res1!=NULL)res1[r[i].second]=k;else arr1[r[i].second]=k;}else{if(res2!=NULL)res2[r[i].second-n1]=k;else arr2[r[i].second-n1]=k;}}return k+1;} template<class S, class T> inline void chmin(S &a, T b){if(a>b)a=b;} template<class S, class T> inline void chmax(S &a, T b){if(a<b)a=b;} template<class T> struct lazySegtreeSum_ChangeOnly{ int N, logN; T *data, *fixval; char *fixed; void malloc(int maxN){int i;for(i=1;i<maxN;i*=2);data=(T*)std::malloc(sizeof(T)*2*i);fixval=(T*)std::malloc(sizeof(T)*i);fixed=(char*)std::malloc(sizeof(char)*i);} T& operator[](int i){return data[N+i];} void setN(int n, int zerofill = 1){int i;for(i=1,logN=0;i<n;i*=2,logN++);N=i;if(zerofill)rep(i,N)data[N+i]=0;} void build(void){int i;for(i=N-1;i;i--)data[i]=data[2*i]+data[2*i+1];REP(i,1,N)fixed[i]=0;} inline void push_one(int a, int sz){if(fixed[a]){if(sz>1)fixed[a*2]=fixed[a*2+1]=1,fixval[a*2]=fixval[a*2+1]=fixval[a],data[a*2]=data[a*2+1]=sz*fixval[a];else data[a*2]=data[a*2+1]=fixval[a];fixed[a] = 0;}} inline void push(int a){int i;for(i=logN;i;i--)push_one(a>>i, 1<<(i-1));} inline void build(int a){int sz=1;while(a>1){a/=2;sz*=2;if(fixed[a])data[a]=fixval[a]*sz;else data[a]=data[a*2]+data[a*2+1];}} inline void change(int a, int b, T val){int sz=1,c,d;if(a>=b)return;c=(a+=N);d=(b+=N);push(a);push(b-1);if(a%2)data[a++]=val;if(b%2)data[--b]=val;a/=2;b/=2;while(a<b){sz*=2;if(a%2)fixed[a]=1,fixval[a]=val,data[a++]=sz*val;if(b%2)fixed[--b]=1,fixval[b]=val,data[b]=sz*val;a/=2;b/=2;}build(c);build(d-1);} inline T getSum(int a, int b){T res;int sz=1;a+=N;b+=N;push(a);push(b-1);res=0;while(a<b){if(a%2)res+=data[a++];if(b%2)res+=data[--b];a/=2;b/=2;}return res;} }; int N, A[100000], r[100000], rev[100000]; int B[100000]; int mn[100000], mx[100000]; int main(){ int i, j, k, m; lazySegtreeSum_ChangeOnly<int> t; reader(&N); rep(i,N) reader(A+i); m = coordinateCompress(N, A, r, mem); rep(i,N) rev[r[i]] = A[i]; rep(i,m) mn[i] = N+1, mx[i] = -1; rep(i,N){ k = r[i]; chmin(mn[k], i); chmax(mx[k], i); } t.malloc(N); t.setN(N); rep(i,m) t.change(mn[i],mx[i]+1,i); rep(i,N) B[i] = t.getSum(i,i+1); rep(i,N) B[i] = rev[B[i]]; writerArr(B, N); return 0; }