Submission #330090

# Submission time Handle Problem Language Result Execution time Memory
330090 2020-11-23T21:28:24 Z Sho10 Xylophone (JOI18_xylophone) C++14
47 / 100
2000 ms 748 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];
map<ll,ll>viz,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 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 5 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 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 5 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 9 ms 364 KB Output is correct
17 Correct 70 ms 364 KB Output is correct
18 Correct 103 ms 492 KB Output is correct
19 Correct 243 ms 492 KB Output is correct
20 Correct 312 ms 492 KB Output is correct
21 Correct 298 ms 492 KB Output is correct
22 Correct 320 ms 492 KB Output is correct
23 Correct 24 ms 492 KB Output is correct
24 Correct 273 ms 532 KB Output is correct
25 Correct 32 ms 492 KB Output is correct
26 Correct 297 ms 532 KB Output is correct
27 Correct 138 ms 748 KB Output is correct
28 Correct 84 ms 620 KB Output is correct
29 Correct 320 ms 532 KB Output is correct
30 Correct 86 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 5 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 9 ms 364 KB Output is correct
17 Correct 70 ms 364 KB Output is correct
18 Correct 103 ms 492 KB Output is correct
19 Correct 243 ms 492 KB Output is correct
20 Correct 312 ms 492 KB Output is correct
21 Correct 298 ms 492 KB Output is correct
22 Correct 320 ms 492 KB Output is correct
23 Correct 24 ms 492 KB Output is correct
24 Correct 273 ms 532 KB Output is correct
25 Correct 32 ms 492 KB Output is correct
26 Correct 297 ms 532 KB Output is correct
27 Correct 138 ms 748 KB Output is correct
28 Correct 84 ms 620 KB Output is correct
29 Correct 320 ms 532 KB Output is correct
30 Correct 86 ms 620 KB Output is correct
31 Correct 619 ms 668 KB Output is correct
32 Execution timed out 3080 ms 748 KB Time limit exceeded
33 Halted 0 ms 0 KB -