답안 #733606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733606 2023-05-01T04:40:30 Z n0sk1ll Xylophone (JOI18_xylophone) C++17
100 / 100
103 ms 468 KB
#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;







//Note to self: Check for overflow

#include "xylophone.h"

int a[5005];
int raz[5005];
int p[5005];

pii nadji(int n)
{
    int l=1;
	int t=0;
	fff(i,2,n)
	{
	    t+=raz[i];
	    if (t<0) t=0,l=i;
	    if (t==n-1) return {l,i};
	}

	fff(i,2,n) raz[i]*=-1;
	l=1,t=0;
	fff(i,2,n)
	{
	    t+=raz[i];
	    if (t<0) t=0,l=i;
	    if (t==n-1) return {l,i};
	}

	return {-1,-1}; //fatally wrong
}

void solve(int n)
{
    raz[2]=query(1,2);

    fff(i,3,n)
    {
        raz[i]=query(i-1,i); if (raz[i-1]<0) raz[i]*=-1;
        if (abs(raz[i])+abs(raz[i-1])!=query(i-2,i)) raz[i]*=-1;
    }

	auto [l,r]=nadji(n);

	a[l]=1,a[r]=n;
	bfff(i,1,l-1)
	{
	    a[i]=a[i+1]-raz[i+1];
	}
	fff(i,r+1,n)
	{
	    a[i]=a[i-1]+raz[i];
	}
	fff(i,l+1,r-1)
	{
	    a[i]=a[i-1]+raz[i];
	}

	fff(i,1,n)
    {
		answer(i, a[i]);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 2 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 208 KB Output is correct
13 Correct 2 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 2 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 208 KB Output is correct
13 Correct 2 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
16 Correct 5 ms 308 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 14 ms 300 KB Output is correct
19 Correct 13 ms 288 KB Output is correct
20 Correct 23 ms 304 KB Output is correct
21 Correct 19 ms 300 KB Output is correct
22 Correct 19 ms 304 KB Output is correct
23 Correct 13 ms 296 KB Output is correct
24 Correct 22 ms 308 KB Output is correct
25 Correct 13 ms 208 KB Output is correct
26 Correct 19 ms 296 KB Output is correct
27 Correct 20 ms 292 KB Output is correct
28 Correct 15 ms 208 KB Output is correct
29 Correct 20 ms 292 KB Output is correct
30 Correct 14 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 2 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 208 KB Output is correct
13 Correct 2 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
16 Correct 5 ms 308 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 14 ms 300 KB Output is correct
19 Correct 13 ms 288 KB Output is correct
20 Correct 23 ms 304 KB Output is correct
21 Correct 19 ms 300 KB Output is correct
22 Correct 19 ms 304 KB Output is correct
23 Correct 13 ms 296 KB Output is correct
24 Correct 22 ms 308 KB Output is correct
25 Correct 13 ms 208 KB Output is correct
26 Correct 19 ms 296 KB Output is correct
27 Correct 20 ms 292 KB Output is correct
28 Correct 15 ms 208 KB Output is correct
29 Correct 20 ms 292 KB Output is correct
30 Correct 14 ms 312 KB Output is correct
31 Correct 43 ms 292 KB Output is correct
32 Correct 45 ms 424 KB Output is correct
33 Correct 65 ms 300 KB Output is correct
34 Correct 63 ms 292 KB Output is correct
35 Correct 101 ms 304 KB Output is correct
36 Correct 65 ms 300 KB Output is correct
37 Correct 75 ms 304 KB Output is correct
38 Correct 85 ms 296 KB Output is correct
39 Correct 78 ms 468 KB Output is correct
40 Correct 61 ms 428 KB Output is correct
41 Correct 93 ms 304 KB Output is correct
42 Correct 99 ms 300 KB Output is correct
43 Correct 78 ms 292 KB Output is correct
44 Correct 79 ms 420 KB Output is correct
45 Correct 78 ms 300 KB Output is correct
46 Correct 79 ms 288 KB Output is correct
47 Correct 85 ms 416 KB Output is correct
48 Correct 72 ms 288 KB Output is correct
49 Correct 84 ms 428 KB Output is correct
50 Correct 76 ms 424 KB Output is correct
51 Correct 61 ms 304 KB Output is correct
52 Correct 96 ms 304 KB Output is correct
53 Correct 80 ms 332 KB Output is correct
54 Correct 88 ms 300 KB Output is correct
55 Correct 73 ms 328 KB Output is correct
56 Correct 92 ms 292 KB Output is correct
57 Correct 85 ms 332 KB Output is correct
58 Correct 90 ms 300 KB Output is correct
59 Correct 67 ms 356 KB Output is correct
60 Correct 103 ms 420 KB Output is correct