Submission #1022697

#TimeUsernameProblemLanguageResultExecution timeMemory
1022697angels Martian DNA (BOI18_dna)C++17
0 / 100
147 ms9236 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k, r; cin>>n>>k>>r; int a[n], b[k+1], visited[k+1]; memset(visited, 0, sizeof(visited)); set<int>barani; for(int i=0; i<k+1; i++) b[i]=-1; for(int i=0; i<n; i++) { cin>>a[i]; } for(int i=0; i<r; i++) { int aa, bb; cin>>aa>>bb; b[aa]=bb; barani.insert(aa); } int vishok=0, manjak=barani.size(), rez=INT_MAX; for(int r=0, l=0; r<n; r++) { bool kiki=0; while(l<r && manjak==0) { if(barani.find(a[l])!=barani.end()) { visited[a[l]]--; if(visited[a[l]]==b[a[l]]-1) { manjak++; kiki=1; visited[a[l]]++; l--; } } l++; } if(kiki) manjak=0; if(manjak==0) { rez=min(r-l, rez); } if(barani.find(a[r])!=barani.end()) { visited[a[r]]++; if(visited[a[r]]==b[a[r]]) { manjak--; } /*if(visited[a[r]]==b[a[r]]+1) { vishok++; }*/ } if(manjak==0) { rez=min(r-l+1, rez); } } /*if(manjak==0) { rez=min(r-l, rez); }*/ if(rez==INT_MAX) cout<<"impossible"; else cout<<rez; return 0; }

Compilation message (stderr)

dna.cpp: In function 'int main()':
dna.cpp:24:9: warning: unused variable 'vishok' [-Wunused-variable]
   24 |     int vishok=0, manjak=barani.size(), rez=INT_MAX;
      |         ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...