답안 #1018111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018111 2024-07-09T14:32:26 Z tigar Xylophone (JOI18_xylophone) C++17
100 / 100
76 ms 1108 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

int ans1[5050], ans2[5050];
int mn2=0, mnp2=1, mn1=0, mnp1=1, mx1=0, mxp1=1, mx2=0, mxp2=1;

/*void answer(int s, int t)
{
    cout<<s<<" "<<t<<endl;
    return;
}

int query(int s, int t)
{
    cout<<s<<" "<<t<<endl;
    int k; cin>>k; return k;
}*/

void solve(int N)
{
    ans1[1]=0; ans2[1]=0;
    ans1[2]=query(1, 2);
    ans2[2]=-ans1[2];
    mn2=ans2[2]; mnp2=2;
    mx1=ans1[2]; mxp1=2;
    int hlast=ans1[2];
    for(int i=3; i<=N; i++)
    {
        int h1=query(i-1, i), h2=query(i-2, i);
        if(hlast+h1==h2)
        {
            if(ans1[i-1]>ans1[i-2])ans1[i]=h1+ans1[i-1];
            else ans1[i]=ans1[i-1]-h1;
            if(ans2[i-1]>ans2[i-2])ans2[i]=h1+ans2[i-1];
            else ans2[i]=ans2[i-1]-h1;
        }
        else
        {
            if(ans1[i-1]<ans1[i-2])ans1[i]=h1+ans1[i-1];
            else ans1[i]=ans1[i-1]-h1;
            if(ans2[i-1]<ans2[i-2])ans2[i]=h1+ans2[i-1];
            else ans2[i]=ans2[i-1]-h1;
        }
        if(ans1[i]<mn1){mn1=min(mn1, ans1[i]); mnp1=i;}
        if(ans2[i]<mn2){mn2=min(mn2, ans2[i]); mnp2=i;}
        if(ans1[i]>mx1){mx1=max(mx1, ans1[i]); mxp1=i;}
        if(ans2[i]>mx2){mx2=max(mx2, ans2[i]); mxp2=i;}
        hlast=h1;
    }
    //cout<<mn1<<" "<<mn2<<endl;
    if(mxp1>mnp1)
    {
        for(int i=1; i<=N; i++)answer(i, ans1[i]-mn1+1);
    }
    else
    {
        for(int i=1; i<=N; i++)answer(i, ans2[i]-mn2+1);
    }
}
# 결과 실행 시간 메모리 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 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 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 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 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 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 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 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 7 ms 344 KB Output is correct
18 Correct 8 ms 600 KB Output is correct
19 Correct 11 ms 344 KB Output is correct
20 Correct 11 ms 448 KB Output is correct
21 Correct 9 ms 704 KB Output is correct
22 Correct 14 ms 344 KB Output is correct
23 Correct 8 ms 344 KB Output is correct
24 Correct 12 ms 440 KB Output is correct
25 Correct 9 ms 600 KB Output is correct
26 Correct 7 ms 444 KB Output is correct
27 Correct 13 ms 596 KB Output is correct
28 Correct 8 ms 448 KB Output is correct
29 Correct 13 ms 600 KB Output is correct
30 Correct 12 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 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 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 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 7 ms 344 KB Output is correct
18 Correct 8 ms 600 KB Output is correct
19 Correct 11 ms 344 KB Output is correct
20 Correct 11 ms 448 KB Output is correct
21 Correct 9 ms 704 KB Output is correct
22 Correct 14 ms 344 KB Output is correct
23 Correct 8 ms 344 KB Output is correct
24 Correct 12 ms 440 KB Output is correct
25 Correct 9 ms 600 KB Output is correct
26 Correct 7 ms 444 KB Output is correct
27 Correct 13 ms 596 KB Output is correct
28 Correct 8 ms 448 KB Output is correct
29 Correct 13 ms 600 KB Output is correct
30 Correct 12 ms 444 KB Output is correct
31 Correct 18 ms 344 KB Output is correct
32 Correct 32 ms 444 KB Output is correct
33 Correct 47 ms 444 KB Output is correct
34 Correct 57 ms 444 KB Output is correct
35 Correct 53 ms 600 KB Output is correct
36 Correct 65 ms 624 KB Output is correct
37 Correct 46 ms 592 KB Output is correct
38 Correct 33 ms 344 KB Output is correct
39 Correct 56 ms 452 KB Output is correct
40 Correct 49 ms 688 KB Output is correct
41 Correct 68 ms 936 KB Output is correct
42 Correct 49 ms 592 KB Output is correct
43 Correct 76 ms 592 KB Output is correct
44 Correct 59 ms 1104 KB Output is correct
45 Correct 60 ms 688 KB Output is correct
46 Correct 51 ms 1108 KB Output is correct
47 Correct 64 ms 600 KB Output is correct
48 Correct 45 ms 600 KB Output is correct
49 Correct 48 ms 688 KB Output is correct
50 Correct 51 ms 344 KB Output is correct
51 Correct 48 ms 592 KB Output is correct
52 Correct 65 ms 1104 KB Output is correct
53 Correct 57 ms 592 KB Output is correct
54 Correct 69 ms 688 KB Output is correct
55 Correct 56 ms 440 KB Output is correct
56 Correct 52 ms 468 KB Output is correct
57 Correct 65 ms 704 KB Output is correct
58 Correct 52 ms 692 KB Output is correct
59 Correct 60 ms 700 KB Output is correct
60 Correct 52 ms 948 KB Output is correct