Submission #1022413

# Submission time Handle Problem Language Result Execution time Memory
1022413 2024-07-13T13:14:39 Z vjudge1 Martian DNA (BOI18_dna) C++17
0 / 100
705 ms 1048576 KB
#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

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 time Memory Grader output
1 Runtime error 564 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 705 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 567 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 580 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -