Submission #1022413

#TimeUsernameProblemLanguageResultExecution timeMemory
1022413vjudge1 Martian DNA (BOI18_dna)C++17
0 / 100
705 ms1048576 KiB
#include<iostream> #include<fstream> #include<cmath> #include<string> #include<vector> #include<algorithm> using namespace std; tuple<int,int,int> mindist(vector<int>&dna,int n,int b,int q,int start,int end) { int br=0; int id1,id2; int mind=200000; for(int i=start;i<end;i++) { int br=0; if(dna[i]==b) { br++; for(int j=i+1;j<end;j++) { if(br==q) { id2=j; break; } if(dna[j]==b) br++; } } mind=min(mind,id2-id1+1); } if(br<q) { if(start-1>=0) mindist(dna,n,b,q,start-1,end); if(end+1<n) mindist(dna,n,b,q,start,end); } } int main() { int n,k,r; cin>>n>>k>>r; vector<int> dna(n); vector<int> rep(k); for(int i=0;i<n;i++) {cin>>dna[i]; rep[dna[i]]++;} for(int i=0;i<k;i++) cout<<rep[i]<<" "; cout<<endl; int mini=200000,maxi=-1; int b,q; cin>>b>>q; if(rep[b]<q) { cout<<"impossible"<<endl; return 0; } int br; tie(br,mini,maxi)=mindist(dna,n,b,q,0,n-1); for(int i=1;i<r;i++) { cin>>b>>q; if(rep[b]<q) { cout<<"impossible"<<endl; return 0; } int tempmin,tempmax; tie(br,tempmin,tempmax)=mindist(dna,n,b,q,mini,maxi); mini=tempmin; maxi=tempmax; } cout<<br<<endl; return 0; }

Compilation message (stderr)

dna.cpp: In function 'std::tuple<int, int, int> mindist(std::vector<int>&, int, int, int, int, int)':
dna.cpp:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...