Submission #938250

# Submission time Handle Problem Language Result Execution time Memory
938250 2024-03-05T03:41:56 Z Faisal_Saqib Sequence (BOI14_sequence) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <string>
#include <set>
using namespace std;
bool is_in(int x,int y)
{
    string s=to_string(x);
    string yp="";
    yp+=char(y+'0');
    return s.find(yp)!=string::npos;
}
int main()
{
    int n;
    cin>>n;
    int b[n];
    set<int> sp;
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        sp.insert(b[i]);
    }
    if(sp.size()==1)
    {
        int tp=1;
        while((tp*10)<=n)
        {
            tp*=10;
        }
        cout<<tp*b[0]<<endl;
        break;
    }
    for(int ans=1;ans<=1e6;ans++)
    {
        bool pos=1;
        for(int j=0;j<n;j++)
        {
            if(!is_in(ans+j,b[j]))
                {
                    pos=0;
                    break;
                }   
        }
        if(pos)
        {
            cout<<ans<<endl;
            break;
        }
    }
    return 0;
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:31:9: error: break statement not within loop or switch
   31 |         break;
      |         ^~~~~