Submission #499550

# Submission time Handle Problem Language Result Execution time Memory
499550 2021-12-28T15:26:17 Z Alisaf9 Lampice (COCI21_lampice) C++14
0 / 50
1 ms 208 KB
#include <iostream>

using namespace std;

int main()
{
    int n,k,l,c=0,z=1,s=0,q,f;
    cin>>n>>k;
    int a[n]={0};
int w[n]={0};
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=1; i<n;i++)
    {
     for(int l=i+1;l<n;l++)
     {
         if(a[l]==a[i])
         {
             q=l;
             f=i;
            while(f<l)
            {
                if(a[q]==a[f])
                {
                    c++;
                    w[s]=a[f];
                }
                else
                {
                    z=0;
                    break;
                }
                q++;
                f++;
            }
            if(z==1)
     break;

     }
     if(z==1)
     break;
    }
    if(z==1)
    {
        for(int i=0;i<q-f;i++)
        {
            cout<<w[i]<<" ";
        }
        cout<<"\n"<<c;

    }
    else
        cout<<-1;
    return 0;
}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:7:13: warning: unused variable 'l' [-Wunused-variable]
    7 |     int n,k,l,c=0,z=1,s=0,q,f;
      |             ^
# Verdict Execution time Memory Grader output
1 OK 1 ms 208 KB Checker has crashed
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 OK 0 ms 204 KB Checker has crashed
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 OK 1 ms 208 KB Checker has crashed
2 Halted 0 ms 0 KB -