답안 #1055052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055052 2024-08-12T14:13:47 Z MrPavlito Xylophone (JOI18_xylophone) C++17
100 / 100
52 ms 972 KB
#include "xylophone.h"
#include <bits/stdc++.h>
//#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define pii pair<int,int>

using namespace std;

const int MAXN = 5000+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;

int querypair[MAXN];
int querytriple[MAXN];
int n;
vector<int>niz(MAXN);

bool resi(bool znak)
{
    vector<int>vis(MAXN,0);
    niz[1] = 0;
    if(znak)niz[2] = querypair[1];
    else niz[2] = -querypair[1];
    for(int i=3; i<=n; i++)
    {
        if(querypair[i-2] + querypair[i-1] != querytriple[i-2])znak = !znak;
        if(znak)niz[i] = niz[i-1] + querypair[i-1];
        else niz[i] = niz[i-1] - querypair[i-1];
    }
    int mn = *min_element(all(niz));
    bool moze = true;
    for(int i=1; i<=n; i++)
    {
        niz[i] = niz[i] -mn + 1;
        if(niz[i] > 0)vis[niz[i]] = i;
    }
    for(int i=1; i<=n; i++)if(vis[i] == 0)moze = false;
    if(vis[1] > vis[n])moze = false;
    return moze;
}



void solve(int N) {
    n = N;
	for(int i=1; i<n; i++)querypair[i] = query(i,i+1);
	for(int i=1; i<n-1; i++)querytriple[i] = query(i,i+2);
	if(resi(true))for(int i=1; i<=n; i++)answer(i, niz[i]);
	else
    {resi(false);
	for(int i=1; i<=n; i++)answer(i, niz[i]);
    }

}
# 결과 실행 시간 메모리 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 2 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 460 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 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 2 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 460 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 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 468 KB Output is correct
17 Correct 4 ms 464 KB Output is correct
18 Correct 7 ms 460 KB Output is correct
19 Correct 8 ms 344 KB Output is correct
20 Correct 8 ms 344 KB Output is correct
21 Correct 10 ms 468 KB Output is correct
22 Correct 8 ms 344 KB Output is correct
23 Correct 11 ms 344 KB Output is correct
24 Correct 7 ms 468 KB Output is correct
25 Correct 5 ms 344 KB Output is correct
26 Correct 8 ms 464 KB Output is correct
27 Correct 8 ms 600 KB Output is correct
28 Correct 10 ms 468 KB Output is correct
29 Correct 9 ms 460 KB Output is correct
30 Correct 8 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 2 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 460 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 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 468 KB Output is correct
17 Correct 4 ms 464 KB Output is correct
18 Correct 7 ms 460 KB Output is correct
19 Correct 8 ms 344 KB Output is correct
20 Correct 8 ms 344 KB Output is correct
21 Correct 10 ms 468 KB Output is correct
22 Correct 8 ms 344 KB Output is correct
23 Correct 11 ms 344 KB Output is correct
24 Correct 7 ms 468 KB Output is correct
25 Correct 5 ms 344 KB Output is correct
26 Correct 8 ms 464 KB Output is correct
27 Correct 8 ms 600 KB Output is correct
28 Correct 10 ms 468 KB Output is correct
29 Correct 9 ms 460 KB Output is correct
30 Correct 8 ms 344 KB Output is correct
31 Correct 17 ms 468 KB Output is correct
32 Correct 22 ms 608 KB Output is correct
33 Correct 33 ms 600 KB Output is correct
34 Correct 36 ms 972 KB Output is correct
35 Correct 45 ms 712 KB Output is correct
36 Correct 34 ms 860 KB Output is correct
37 Correct 39 ms 728 KB Output is correct
38 Correct 44 ms 716 KB Output is correct
39 Correct 38 ms 600 KB Output is correct
40 Correct 42 ms 716 KB Output is correct
41 Correct 41 ms 720 KB Output is correct
42 Correct 39 ms 600 KB Output is correct
43 Correct 45 ms 460 KB Output is correct
44 Correct 39 ms 600 KB Output is correct
45 Correct 38 ms 460 KB Output is correct
46 Correct 46 ms 720 KB Output is correct
47 Correct 44 ms 600 KB Output is correct
48 Correct 41 ms 716 KB Output is correct
49 Correct 37 ms 596 KB Output is correct
50 Correct 49 ms 720 KB Output is correct
51 Correct 40 ms 960 KB Output is correct
52 Correct 52 ms 600 KB Output is correct
53 Correct 38 ms 592 KB Output is correct
54 Correct 51 ms 464 KB Output is correct
55 Correct 32 ms 724 KB Output is correct
56 Correct 35 ms 460 KB Output is correct
57 Correct 42 ms 472 KB Output is correct
58 Correct 47 ms 732 KB Output is correct
59 Correct 27 ms 344 KB Output is correct
60 Correct 51 ms 344 KB Output is correct