Submission #201393

# Submission time Handle Problem Language Result Execution time Memory
201393 2020-02-10T11:10:17 Z Shelby Drvca (COCI19_drvca) C++11
0 / 110
47 ms 3688 KB
#include <bits/stdc++.h>
#define MAXN 100005
using namespace std;

int a[MAXN],n;
bool f[MAXN];

bool check(int start,int d)
{
    int now=a[start];

    vector<int> v;

    f[start]=true;

    for(int i=start;i<n;i++)
    {
        if( (now+d)==a[i] )
        {
            f[i]=true;

            now=a[i];
        }
    }

    for(int i=0;i<n;i++)
    {
        if(f[i]==false) v.push_back(a[i]);
    }

    if(v.size()<=1) return true;
    else
    {
        int tmp=v[1]-v[0];

        for(int i=1;i<v.size();i++)
        {
            if( (v[i]-v[i-1])!=tmp ) return false;
        }

        return true;
    }
}

void restart()
{
    for(int i=0;i<n;i++) f[i]=false;
}

void ispisi()
{
    vector<int> gr1;
    vector<int> gr2;

    for(int i=0;i<n;i++)
    {
        if(f[i]==true) gr2.push_back(a[i]);

        if(f[i]==false) gr1.push_back(a[i]);
    }

    printf("%d\n",gr1.size());
    for(int i=0;i<gr1.size();i++) printf("%d ",gr1[i]);

    printf("\n");

    printf("%d\n",gr2.size());
    for(int i=0;i<gr2.size();i++) printf("%d ",gr2[i]);
}

int main()
{ int i,d;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&a[i]);

sort(a,a+n);

d=a[2]-a[1];

restart();

if(check(1,d)) ispisi();
else
{
    restart();

    d=a[2]-a[0];

    if(check(0,d)) ispisi();
    else
    {
        restart();

        d=a[1]-a[0];

        if(check(0,d)) ispisi();
        else printf("-1\n");
    }
}

    return 0;
}

Compilation message

drvca.cpp: In function 'bool check(int, int)':
drvca.cpp:36:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=1;i<v.size();i++)
                     ~^~~~~~~~~
drvca.cpp: In function 'void ispisi()':
drvca.cpp:62:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",gr1.size());
                   ~~~~~~~~~~^
drvca.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<gr1.size();i++) printf("%d ",gr1[i]);
                 ~^~~~~~~~~~~
drvca.cpp:67:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",gr2.size());
                   ~~~~~~~~~~^
drvca.cpp:68:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<gr2.size();i++) printf("%d ",gr2[i]);
                 ~^~~~~~~~~~~
drvca.cpp: In function 'int main()':
drvca.cpp:73:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d",&n);
 ~~~~~^~~~~~~~~
drvca.cpp:74:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 for(i=0;i<n;i++) scanf("%d",&a[i]);
                  ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 404 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Incorrect 5 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 404 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Incorrect 5 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 3540 KB Output is correct
2 Correct 46 ms 3436 KB Output is correct
3 Correct 47 ms 3688 KB Output is correct
4 Correct 45 ms 3436 KB Output is correct
5 Correct 45 ms 3440 KB Output is correct
6 Correct 46 ms 3568 KB Output is correct
7 Correct 43 ms 3440 KB Output is correct
8 Correct 45 ms 3568 KB Output is correct
9 Incorrect 33 ms 2220 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 404 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Incorrect 5 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -