Submission #330092

# Submission time Handle Problem Language Result Execution time Memory
330092 2020-11-23T21:30:43 Z Sho10 Xylophone (JOI18_xylophone) C++14
100 / 100
334 ms 672 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#include "xylophone.h"
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod (10*10*10*10*10*10*10*10*10+7)
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[5005],s1[5005],s2[5005],viz[5005],v[5005];
ll check(){
    ll nr=0;
for(ll i=1;i<=n;i++)
{
    if(v[i]==1){
        nr=1;
    }
    if(nr==0&&v[i]==n){
        return 0;
    }
    if(v[i]<1||v[i]>n){
        return 0;
    }
}
return 1;
}
void solve(int N){
    n=N;
for(ll i=1;i<n;i++)
{
    s1[i]=query(i,i+1);
}
for(ll i=1;i<n-1;i++)
{
    s2[i]=query(i,i+2);
}
for(ll i=3;i<=n;i++)
{
    if(s1[i-2]+s1[i-1]==s2[i-2]){
        viz[i]=0;
    }else {
    viz[i]=1;
    }
}
for(ll i=1;i<=n;i++)
{
    for(ll j=0;j<2;j++)
    {
        memset(v,0,sizeof(v));
        v[1]=i;
        ll x=j;
        for(ll k=2;k<=n;k++)
        {
            if(x){
                v[k]=v[k-1]+s1[k-1];
            }else v[k]=v[k-1]-s1[k-1];
            if(k+1<=n&&viz[k+1]){
                x^=1;
            }
        }
        if(check()){
            for(ll i=1;i<=n;i++)
            {
                answer(i,v[i]);
            }
            return;
        }
    }
}
}
/*
int32_t main(){
CODE_START;
v[1]=2;
v[2]=1;
v[3]=5;
v[4]=3;
v[5]=4;
solve(5);
}
*/


# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 10 ms 392 KB Output is correct
18 Correct 17 ms 364 KB Output is correct
19 Correct 28 ms 364 KB Output is correct
20 Correct 27 ms 364 KB Output is correct
21 Correct 19 ms 384 KB Output is correct
22 Correct 25 ms 364 KB Output is correct
23 Correct 16 ms 364 KB Output is correct
24 Correct 19 ms 364 KB Output is correct
25 Correct 19 ms 364 KB Output is correct
26 Correct 29 ms 364 KB Output is correct
27 Correct 24 ms 364 KB Output is correct
28 Correct 20 ms 384 KB Output is correct
29 Correct 26 ms 364 KB Output is correct
30 Correct 23 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 10 ms 392 KB Output is correct
18 Correct 17 ms 364 KB Output is correct
19 Correct 28 ms 364 KB Output is correct
20 Correct 27 ms 364 KB Output is correct
21 Correct 19 ms 384 KB Output is correct
22 Correct 25 ms 364 KB Output is correct
23 Correct 16 ms 364 KB Output is correct
24 Correct 19 ms 364 KB Output is correct
25 Correct 19 ms 364 KB Output is correct
26 Correct 29 ms 364 KB Output is correct
27 Correct 24 ms 364 KB Output is correct
28 Correct 20 ms 384 KB Output is correct
29 Correct 26 ms 364 KB Output is correct
30 Correct 23 ms 364 KB Output is correct
31 Correct 70 ms 412 KB Output is correct
32 Correct 149 ms 556 KB Output is correct
33 Correct 127 ms 492 KB Output is correct
34 Correct 222 ms 568 KB Output is correct
35 Correct 254 ms 492 KB Output is correct
36 Correct 116 ms 620 KB Output is correct
37 Correct 191 ms 492 KB Output is correct
38 Correct 118 ms 492 KB Output is correct
39 Correct 91 ms 620 KB Output is correct
40 Correct 167 ms 620 KB Output is correct
41 Correct 255 ms 620 KB Output is correct
42 Correct 77 ms 512 KB Output is correct
43 Correct 187 ms 620 KB Output is correct
44 Correct 60 ms 620 KB Output is correct
45 Correct 147 ms 492 KB Output is correct
46 Correct 244 ms 672 KB Output is correct
47 Correct 279 ms 644 KB Output is correct
48 Correct 74 ms 492 KB Output is correct
49 Correct 230 ms 628 KB Output is correct
50 Correct 233 ms 620 KB Output is correct
51 Correct 154 ms 492 KB Output is correct
52 Correct 121 ms 492 KB Output is correct
53 Correct 246 ms 620 KB Output is correct
54 Correct 232 ms 492 KB Output is correct
55 Correct 255 ms 620 KB Output is correct
56 Correct 298 ms 492 KB Output is correct
57 Correct 245 ms 620 KB Output is correct
58 Correct 334 ms 492 KB Output is correct
59 Correct 198 ms 492 KB Output is correct
60 Correct 187 ms 492 KB Output is correct