Submission #330091

# Submission time Handle Problem Language Result Execution time Memory
330091 2020-11-23T21:29:41 Z Sho10 Xylophone (JOI18_xylophone) C++14
47 / 100
2000 ms 652 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];
map<ll,ll>v;
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++)
    {
        v.clear();
        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 492 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 2 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 3 ms 364 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 3 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 492 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 2 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 3 ms 364 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 7 ms 364 KB Output is correct
17 Correct 47 ms 364 KB Output is correct
18 Correct 69 ms 364 KB Output is correct
19 Correct 172 ms 364 KB Output is correct
20 Correct 213 ms 364 KB Output is correct
21 Correct 217 ms 364 KB Output is correct
22 Correct 216 ms 384 KB Output is correct
23 Correct 22 ms 364 KB Output is correct
24 Correct 199 ms 392 KB Output is correct
25 Correct 20 ms 364 KB Output is correct
26 Correct 208 ms 492 KB Output is correct
27 Correct 103 ms 364 KB Output is correct
28 Correct 66 ms 376 KB Output is correct
29 Correct 213 ms 364 KB Output is correct
30 Correct 59 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 2 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 3 ms 364 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 7 ms 364 KB Output is correct
17 Correct 47 ms 364 KB Output is correct
18 Correct 69 ms 364 KB Output is correct
19 Correct 172 ms 364 KB Output is correct
20 Correct 213 ms 364 KB Output is correct
21 Correct 217 ms 364 KB Output is correct
22 Correct 216 ms 384 KB Output is correct
23 Correct 22 ms 364 KB Output is correct
24 Correct 199 ms 392 KB Output is correct
25 Correct 20 ms 364 KB Output is correct
26 Correct 208 ms 492 KB Output is correct
27 Correct 103 ms 364 KB Output is correct
28 Correct 66 ms 376 KB Output is correct
29 Correct 213 ms 364 KB Output is correct
30 Correct 59 ms 364 KB Output is correct
31 Correct 442 ms 492 KB Output is correct
32 Execution timed out 2826 ms 652 KB Time limit exceeded
33 Halted 0 ms 0 KB -