답안 #256566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256566 2020-08-02T20:59:41 Z DavidDamian Xylophone (JOI18_xylophone) C++11
100 / 100
265 ms 636 KB
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
///Subtask 3
///2N queries
///Ask for i,i+1 and i,i+2
///Determine the direction of the changes with adj3[i]==adj2[i]+adj2[i+1]
int a[5005];
int adj2[5005]; //Differences of pairs
int adj3[5005]; //Differences of triples
int same[5005];
bool found=false;
void build(int n,int k,int dir)
{
    bool one=false;
    a[1]=k;
    for(int i=1;i<=n-1;i++){
        if(a[i]==1) one=true;
        if(!same[i]) dir*=-1;
        a[i+1]=a[i]+dir*adj2[i];
        if(a[i+1]<1 || a[i+1]>n)
            return;
        if(a[i+1]==n && !one)
            return;
    }
    found=true;
}
void print(int n)
{
    for(int i=1;i<=n;i++){
        answer(i,a[i]);
    }
}
void solve(int N) {
    if(N==2){
        answer(1,1);
        answer(2,2);
        return;
    }
    for(int i=1;i<=N-2;i++){
        adj2[i]=query(i,i+1);
        adj3[i]=query(i,i+2);
    }
    adj2[N-1]=query(N-1,N);
    same[1]=1;
    for(int i=1;i<=N-2;i++){
        if(adj3[i]==adj2[i]+adj2[i+1])
            same[i+1]=1;
    }
    for(int i=1;i<=N;i++){
        build(N,i,1);
        if(found){
            print(N);
            return;
        }
        build(N,i,-1);
        if(found){
            print(N);
            return;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 372 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 8 ms 384 KB Output is correct
18 Correct 25 ms 376 KB Output is correct
19 Correct 16 ms 384 KB Output is correct
20 Correct 26 ms 376 KB Output is correct
21 Correct 19 ms 384 KB Output is correct
22 Correct 30 ms 376 KB Output is correct
23 Correct 16 ms 384 KB Output is correct
24 Correct 27 ms 376 KB Output is correct
25 Correct 17 ms 384 KB Output is correct
26 Correct 23 ms 504 KB Output is correct
27 Correct 26 ms 376 KB Output is correct
28 Correct 25 ms 384 KB Output is correct
29 Correct 16 ms 384 KB Output is correct
30 Correct 24 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 372 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 8 ms 384 KB Output is correct
18 Correct 25 ms 376 KB Output is correct
19 Correct 16 ms 384 KB Output is correct
20 Correct 26 ms 376 KB Output is correct
21 Correct 19 ms 384 KB Output is correct
22 Correct 30 ms 376 KB Output is correct
23 Correct 16 ms 384 KB Output is correct
24 Correct 27 ms 376 KB Output is correct
25 Correct 17 ms 384 KB Output is correct
26 Correct 23 ms 504 KB Output is correct
27 Correct 26 ms 376 KB Output is correct
28 Correct 25 ms 384 KB Output is correct
29 Correct 16 ms 384 KB Output is correct
30 Correct 24 ms 504 KB Output is correct
31 Correct 52 ms 632 KB Output is correct
32 Correct 44 ms 384 KB Output is correct
33 Correct 87 ms 520 KB Output is correct
34 Correct 69 ms 384 KB Output is correct
35 Correct 116 ms 504 KB Output is correct
36 Correct 123 ms 384 KB Output is correct
37 Correct 265 ms 384 KB Output is correct
38 Correct 49 ms 384 KB Output is correct
39 Correct 76 ms 384 KB Output is correct
40 Correct 84 ms 504 KB Output is correct
41 Correct 61 ms 384 KB Output is correct
42 Correct 79 ms 384 KB Output is correct
43 Correct 141 ms 384 KB Output is correct
44 Correct 83 ms 508 KB Output is correct
45 Correct 87 ms 384 KB Output is correct
46 Correct 80 ms 504 KB Output is correct
47 Correct 90 ms 504 KB Output is correct
48 Correct 83 ms 384 KB Output is correct
49 Correct 77 ms 504 KB Output is correct
50 Correct 81 ms 636 KB Output is correct
51 Correct 88 ms 380 KB Output is correct
52 Correct 80 ms 504 KB Output is correct
53 Correct 125 ms 384 KB Output is correct
54 Correct 126 ms 400 KB Output is correct
55 Correct 47 ms 376 KB Output is correct
56 Correct 81 ms 636 KB Output is correct
57 Correct 75 ms 384 KB Output is correct
58 Correct 64 ms 384 KB Output is correct
59 Correct 86 ms 384 KB Output is correct
60 Correct 78 ms 384 KB Output is correct