Submission #317062

# Submission time Handle Problem Language Result Execution time Memory
317062 2020-10-29T02:02:12 Z daniel920712 DEL13 (info1cup18_del13) C++14
6 / 100
8 ms 512 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;
int all[100005];
vector < int > tt;
int T,N,M;
int F(int l,int r)
{
    int x,ok=1,i;
    tt.clear();
    for(i=l;i<=r;i++)
    {
        if(i==0)
        {
            if(all[i]!=1) tt.push_back(all[i]-1);
        }
        else if(all[i]-all[i-1]-1) tt.push_back(all[i]-all[i-1]-1);
    }
    if(r==M-1)
    {
        if(all[r]!=N) tt.push_back(N-all[r]);
    }
    else if(all[r+1]-all[r]-1)
    {
        tt.push_back(all[r+1]-all[r]-1);
    }

    if(tt.empty()) return 1;
    if(tt.size()==1) return 0;
    x=tt[0]%2;
    for(auto i:tt)
    {
        if(x!=i%2) return 0;
    }
    return 1;

}
int main()
{
    int i,j,con,xx=0,ok=1,last;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d %d",&N,&M);
        ok=1;
        last=0;
        for(i=0;i<M;i++) scanf("%d",&all[i]);
        if((N-M)%2) printf("-1\n");
        else
        {

            for(i=1;i<M;i++)
            {
                if(all[i]-all[i-1]==1)
                {
                    ok=ok&F(last,i-1);
                    last=i;
                }
            }
            ok=ok&&F(last,M-1);
            printf("%d\n",ok-1);
        }
    }

    return 0;
}

Compilation message

del13.cpp: In function 'int F(int, int)':
del13.cpp:14:11: warning: unused variable 'ok' [-Wunused-variable]
   14 |     int x,ok=1,i;
      |           ^~
del13.cpp: In function 'int main()':
del13.cpp:45:11: warning: unused variable 'j' [-Wunused-variable]
   45 |     int i,j,con,xx=0,ok=1,last;
      |           ^
del13.cpp:45:13: warning: unused variable 'con' [-Wunused-variable]
   45 |     int i,j,con,xx=0,ok=1,last;
      |             ^~~
del13.cpp:45:17: warning: unused variable 'xx' [-Wunused-variable]
   45 |     int i,j,con,xx=0,ok=1,last;
      |                 ^~
del13.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |     scanf("%d",&T);
      |     ~~~~~^~~~~~~~~
del13.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   49 |         scanf("%d %d",&N,&M);
      |         ~~~~~^~~~~~~~~~~~~~~
del13.cpp:52:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |         for(i=0;i<M;i++) scanf("%d",&all[i]);
      |                          ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Incorrect 4 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is partially correct
2 Correct 2 ms 384 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Incorrect 4 ms 256 KB Output isn't correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Incorrect 1 ms 256 KB Output isn't correct
7 Incorrect 1 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Incorrect 4 ms 256 KB Output isn't correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Incorrect 1 ms 256 KB Output isn't correct
7 Incorrect 1 ms 256 KB Output isn't correct
8 Incorrect 7 ms 384 KB Output isn't correct
9 Incorrect 8 ms 384 KB Output isn't correct
10 Incorrect 8 ms 512 KB Output isn't correct
11 Incorrect 8 ms 512 KB Output isn't correct