Submission #330808

# Submission time Handle Problem Language Result Execution time Memory
330808 2020-11-26T16:08:41 Z Fidisk Xylophone (JOI18_xylophone) C++14
0 / 100
1 ms 364 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

const ll mod=1e9+7;

bool ok[5009];
int a[5009],type[5009],ans[5009],last,i,j,n,b[5009];

bool check(int x,int t) {
    last=1;
    ms(ok,false);
    ans[1]=x;
    ok[x]=true;
    if (t==1) {
        for (int ii=1;ii<=n;ii++) {
            if (type[ii]==1) {
                if (last==1) {
                    ans[ii]=ans[ii-1]+a[ii-1];
                }
                else {
                    ans[ii]=ans[ii-1]-a[ii-1];
                }
            }
            else {
                if (last==1) {
                    ans[ii]=ans[ii-1]-a[ii-1];
                }
                else {
                    ans[ii]=ans[ii-1]+a[ii-1];
                }
            }
            if (!ok[ans[ii]]) {
                ok[ans[ii]]=true;
            }
            else {
                return false;
            }
        }
    }
    else {
        last=0;
        for (int ii=1;ii<=n;ii++) {
            if (type[ii]==1) {
                if (last==1) {
                    ans[ii]=ans[ii-1]+a[ii-1];
                }
                else {
                    ans[ii]=ans[ii-1]-a[ii-1];
                }
            }
            else {
                if (last==1) {
                    ans[ii]=ans[ii-1]-a[ii-1];
                }
                else {
                    ans[ii]=ans[ii-1]+a[ii-1];
                }
            }
            if (!ok[ans[ii]]&&ans[ii]>=1&&ans[ii]<=n) {
                ok[ans[ii]]=true;
            }
            else {
                return false;
            }
        }
    }
    return true;
}

void solve(int n) {
    if (n==2) {
        answer(1,1);
        answer(2,2);
        return;
    }
    for (i=1;i<n;i++) {
        a[i]=query(i,i+1);
    }
    for (i=1;i<n-1;i++) {
        b[i]=query(i,i+2);
    }
    for (i=1;i<=n-2;i++) {
        if (a[i]==b[i]||a[i+1]==b[i]) {
            type[i+1]=1;
        }
        else {
            type[i+1]=0;
        }
    }
    for (i=1;i<=n;i++) {
        if (check(i,1)) {
            for (j=1;j<=n;j++) {
                answer(i,a[i]);
            }
        }
        if (check(i,0)) {
            for (j=1;j<=n;j++) {
                answer(i,a[i]);
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -