답안 #996081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996081 2024-06-10T07:46:24 Z vjudge1 Xylophone (JOI18_xylophone) C++17
100 / 100
78 ms 1164 KB
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int N=5e3;
int a[N+5],x[N+5];
void solve(int n){
    vector <pair<int,int>> v;
    int dist=query(1,2);
    for (int i=3;i<=n;++i){
        int x=query(i-1,i);
        int y=query(i-2,i);
        v.push_back({x,y});
    }
    a[1]=1e9;
    a[2]=1e9+dist;
    x[1]=x[2]=0;
    int bruh=min(a[1],a[2]);
    for (int i=3;i<=n;++i){
        x[i]=0;
        int d=a[i-1]+v[i-3].first;
        if (max(d,max(a[i-1],a[i-2]))-min(d,min(a[i-1],a[i-2]))==v[i-3].second) a[i]=d;
        else a[i]=a[i-1]-v[i-3].first;
        bruh=min(bruh,a[i]);
    }
    --bruh;
    for (int i=1;i<=n;++i) a[i]-=bruh,x[a[i]]=i;
    bool ok=true;
    for (int i=1;i<=n;++i)
        if (!x[i]) ok=false;
    if (x[1]>x[n]) ok=false;
    if (ok){
        for (int i=1;i<=n;++i) answer(i,a[i]);
        fflush(stdout);
        return;
    }
    a[1]=1e9;
    a[2]=1e9-dist;
    bruh=min(a[1],a[2]);
    for (int i=3;i<=n;++i){
        x[i]=0;
        int d=a[i-1]+v[i-3].first;
        if (max(d,max(a[i-1],a[i-2]))-min(d,min(a[i-1],a[i-2]))==v[i-3].second) a[i]=d;
        else a[i]=a[i-1]-v[i-3].first;
        bruh=min(bruh,a[i]);
    }
    --bruh;
    for (int i=1;i<=n;++i) a[i]-=bruh;
    for (int i=1;i<=n;++i) answer(i,a[i]);
    fflush(stdout);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 13 ms 448 KB Output is correct
20 Correct 8 ms 676 KB Output is correct
21 Correct 11 ms 344 KB Output is correct
22 Correct 10 ms 456 KB Output is correct
23 Correct 9 ms 440 KB Output is correct
24 Correct 11 ms 456 KB Output is correct
25 Correct 10 ms 700 KB Output is correct
26 Correct 11 ms 600 KB Output is correct
27 Correct 9 ms 344 KB Output is correct
28 Correct 12 ms 344 KB Output is correct
29 Correct 11 ms 604 KB Output is correct
30 Correct 9 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 13 ms 448 KB Output is correct
20 Correct 8 ms 676 KB Output is correct
21 Correct 11 ms 344 KB Output is correct
22 Correct 10 ms 456 KB Output is correct
23 Correct 9 ms 440 KB Output is correct
24 Correct 11 ms 456 KB Output is correct
25 Correct 10 ms 700 KB Output is correct
26 Correct 11 ms 600 KB Output is correct
27 Correct 9 ms 344 KB Output is correct
28 Correct 12 ms 344 KB Output is correct
29 Correct 11 ms 604 KB Output is correct
30 Correct 9 ms 444 KB Output is correct
31 Correct 16 ms 600 KB Output is correct
32 Correct 30 ms 452 KB Output is correct
33 Correct 44 ms 476 KB Output is correct
34 Correct 65 ms 700 KB Output is correct
35 Correct 51 ms 620 KB Output is correct
36 Correct 47 ms 468 KB Output is correct
37 Correct 63 ms 620 KB Output is correct
38 Correct 56 ms 704 KB Output is correct
39 Correct 51 ms 776 KB Output is correct
40 Correct 67 ms 740 KB Output is correct
41 Correct 78 ms 600 KB Output is correct
42 Correct 67 ms 652 KB Output is correct
43 Correct 46 ms 1164 KB Output is correct
44 Correct 50 ms 592 KB Output is correct
45 Correct 58 ms 344 KB Output is correct
46 Correct 44 ms 852 KB Output is correct
47 Correct 43 ms 720 KB Output is correct
48 Correct 43 ms 724 KB Output is correct
49 Correct 66 ms 600 KB Output is correct
50 Correct 41 ms 592 KB Output is correct
51 Correct 71 ms 712 KB Output is correct
52 Correct 39 ms 344 KB Output is correct
53 Correct 75 ms 732 KB Output is correct
54 Correct 45 ms 712 KB Output is correct
55 Correct 33 ms 852 KB Output is correct
56 Correct 53 ms 600 KB Output is correct
57 Correct 62 ms 736 KB Output is correct
58 Correct 48 ms 848 KB Output is correct
59 Correct 47 ms 344 KB Output is correct
60 Correct 64 ms 444 KB Output is correct