Submission #1180712
Source Code Expand
#include <bits/stdc++.h> using namespace std; int N,M,Q; int b[100005],c[100005],d[100005],e[100005],f[100005]; bool g[100005]; vector<int> a,v; const int INF=1000000009; int main(){ cin>>N>>M>>Q; for(int i=0; i<Q; i++){ int x; scanf("%d",&x); a.push_back(x); b[i]=x; c[x]++; } sort(b,b+Q); M=b[Q-1]; int j=1; for(int i=Q-1; i>=0; i--){ if(!g[a[i]]){ d[j]=a[i]; g[a[i]]=1; j++; } } for(int i=1; i<=M; i++){ if(g[i]==0){ v.push_back(i); } } for(int i=j; i<=M; i++){ d[i]=v[0]; v.erase(v.begin()); } int esize=M; bool no=1; for(int i=M-1; i>=1; i--){ if(d[i]>d[i+1]){ esize=i; no=0; break; } } if(no){ cout<<"Yes"<<endl; return 0; } int k=1; for(int i=esize; i>=1; i--){ e[k]=d[i]; k++; } int count=0,time=0; bool find=0; while(1){ k=1; find=0; for(int i=0; i<a.size(); i++){ if(a[i]==e[k]) k++; if(k==esize+1){ count++; k=1; find=1; } } if(!find) break; if(count>=N) break; k=1; for(int i=0; i<a.size(); i++){ if(a[i]==e[k]){ a.erase(a.begin()+i); k++; } if(k==esize+1){ if(time==count) break; time++; k=1; } } } if(count>=N) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - LRU Puzzle |
User | momotaro1303 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1320 Byte |
Status | WA |
Exec Time | 507 ms |
Memory | 2424 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:19:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&x); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1200 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt, 1_64.txt, 1_65.txt, 1_66.txt, 1_67.txt, 1_68.txt, 1_69.txt, 1_70.txt, 1_71.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 10 ms | 1148 KB |
1_03.txt | AC | 10 ms | 1148 KB |
1_04.txt | AC | 10 ms | 1148 KB |
1_05.txt | WA | 363 ms | 1148 KB |
1_06.txt | AC | 13 ms | 2040 KB |
1_07.txt | AC | 14 ms | 2424 KB |
1_08.txt | AC | 13 ms | 2040 KB |
1_09.txt | AC | 13 ms | 2040 KB |
1_10.txt | AC | 18 ms | 1784 KB |
1_11.txt | AC | 18 ms | 1784 KB |
1_12.txt | AC | 19 ms | 1784 KB |
1_13.txt | AC | 19 ms | 1784 KB |
1_14.txt | AC | 366 ms | 1784 KB |
1_15.txt | AC | 365 ms | 1784 KB |
1_16.txt | AC | 365 ms | 1784 KB |
1_17.txt | AC | 365 ms | 1784 KB |
1_18.txt | WA | 18 ms | 1912 KB |
1_19.txt | AC | 19 ms | 1784 KB |
1_20.txt | WA | 18 ms | 1912 KB |
1_21.txt | AC | 19 ms | 2424 KB |
1_22.txt | WA | 29 ms | 2040 KB |
1_23.txt | AC | 69 ms | 2168 KB |
1_24.txt | WA | 23 ms | 2040 KB |
1_25.txt | AC | 24 ms | 2040 KB |
1_26.txt | AC | 14 ms | 1148 KB |
1_27.txt | AC | 13 ms | 1148 KB |
1_28.txt | WA | 19 ms | 1148 KB |
1_29.txt | AC | 16 ms | 1148 KB |
1_30.txt | AC | 332 ms | 2040 KB |
1_31.txt | AC | 377 ms | 2168 KB |
1_32.txt | AC | 208 ms | 1912 KB |
1_33.txt | AC | 400 ms | 2168 KB |
1_34.txt | WA | 18 ms | 1400 KB |
1_35.txt | AC | 19 ms | 1656 KB |
1_36.txt | WA | 20 ms | 1400 KB |
1_37.txt | AC | 19 ms | 1656 KB |
1_38.txt | WA | 22 ms | 1912 KB |
1_39.txt | AC | 19 ms | 1912 KB |
1_40.txt | WA | 93 ms | 2296 KB |
1_41.txt | AC | 41 ms | 2424 KB |
1_42.txt | AC | 15 ms | 1148 KB |
1_43.txt | AC | 17 ms | 1148 KB |
1_44.txt | AC | 15 ms | 1148 KB |
1_45.txt | AC | 15 ms | 1148 KB |
1_46.txt | WA | 31 ms | 1276 KB |
1_47.txt | AC | 92 ms | 1784 KB |
1_48.txt | WA | 71 ms | 1528 KB |
1_49.txt | AC | 507 ms | 2296 KB |
1_50.txt | AC | 67 ms | 1148 KB |
1_51.txt | WA | 15 ms | 1148 KB |
1_52.txt | AC | 36 ms | 1272 KB |
1_53.txt | AC | 17 ms | 1148 KB |
1_54.txt | AC | 15 ms | 1148 KB |
1_55.txt | WA | 127 ms | 1400 KB |
1_56.txt | AC | 18 ms | 1400 KB |
1_57.txt | AC | 474 ms | 2296 KB |
1_58.txt | AC | 12 ms | 1148 KB |
1_59.txt | AC | 14 ms | 1148 KB |
1_60.txt | AC | 12 ms | 1148 KB |
1_61.txt | AC | 15 ms | 1148 KB |
1_62.txt | AC | 58 ms | 1400 KB |
1_63.txt | AC | 359 ms | 1784 KB |
1_64.txt | AC | 11 ms | 1148 KB |
1_65.txt | AC | 431 ms | 2168 KB |
1_66.txt | AC | 11 ms | 1148 KB |
1_67.txt | AC | 247 ms | 1148 KB |
1_68.txt | AC | 11 ms | 1148 KB |
1_69.txt | AC | 15 ms | 1148 KB |
1_70.txt | AC | 11 ms | 1148 KB |
1_71.txt | AC | 334 ms | 1912 KB |