Submission #340171

# Submission time Handle Problem Language Result Execution time Memory
340171 2020-12-27T07:23:11 Z beksultan04 Crazy old lady (IZhO13_crazy) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define ll long long
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 2e5+12,INF=1e9+7;
int q[N],p[N],n;

bool is(int x){
    p[x]=1;
    int i,c=1;
    for (i=2;i<=n;++i){
        if (i-1 > x)c=0;
        if (p[i-c] == 0 && q[i] != i-c)ret 0;
        p[q[i]]=1;
    c=1;
    }
    ret 1;
}


main(){
    int t;
    scan1(t)
    while (t--){
        int i,j,s=0,cnt=0;
        scan1(n)
        for (i=1;i<=n;++i)
            scan1(q[i])
        for (i=1;i<=n;++i){
            if (is(i)){
                s=i;
                cnt++;
            }
            for (j=1;j<=n;++j)p[j]=0;
        }
        if (cnt >1)s=0;
        cout <<s<<"\n";
    }
}

Compilation message

crazy.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      |      ^
crazy.cpp: In function 'int main()':
crazy.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan1(a) scanf("%d",&a);
      |                  ~~~~~^~~~~~~~~
crazy.cpp:37:5: note: in expansion of macro 'scan1'
   37 |     scan1(t)
      |     ^~~~~
crazy.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan1(a) scanf("%d",&a);
      |                  ~~~~~^~~~~~~~~
crazy.cpp:40:9: note: in expansion of macro 'scan1'
   40 |         scan1(n)
      |         ^~~~~
crazy.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan1(a) scanf("%d",&a);
      |                  ~~~~~^~~~~~~~~
crazy.cpp:42:13: note: in expansion of macro 'scan1'
   42 |             scan1(q[i])
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -