Submission #702847

# Submission time Handle Problem Language Result Execution time Memory
702847 2023-02-25T08:56:09 Z kxd Xylophone (JOI18_xylophone) C++17
100 / 100
111 ms 452 KB
#include "xylophone.h"
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define pb push_back
#define p_q priority_queue
#define m_p make_pair
#define pii pair<int,int>
#define endl '\n'
#define INIT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define forn(i, n) for (int i = 0; i < n; i++)
#define forn1(i, n) for (int i = 1; i <= n; i++)
#define all(x) x.begin(),x.end()
#define ft first
#define sd second

using namespace std;
const int N = 6969;
const int INF = 1e9;
const int MOD = 1e9+7;

int a[N];
int nx[N];
int nx3[N];
bool bl[N];

void solve(int n) {
	for(int i = 1; i < n; i++) {
		nx[i] = query(i,i+1);
	}
	for(int i = 1; i < n-1; i++) {
		nx3[i] = query(i,i+2);
	}
	for(int i = 2; i < n; i++) {
		bl[i] = (nx3[i-1] != nx[i-1] + nx[i]);
	}
	a[1] = 1;
	bool flag = 1;
	for(int i = 2; i <= n; i++) {
		if(flag) a[i] = a[i-1]+nx[i-1];
		else a[i] = a[i-1]-nx[i-1];
		flag = flag^bl[i];
	}
	int min_ = INF;
	forn1(i,n) {
		min_ = min(min_,a[i]);
	}
	forn1(i,n) {
		a[i] += 1 - min_;
	}
	int pos1, posn;
	forn1(i,n) {
		if(a[i] == 1) pos1 = i;
		if(a[i] == n) posn = i;
	}	
	if(pos1 > posn) {
		forn1(i,n) {
			a[i] = n+1-a[i];
		}
	}
	forn1(i,n) answer(i, a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:57:2: warning: 'posn' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |  if(pos1 > posn) {
      |  ^~
xylophone.cpp:57:2: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 308 KB Output is correct
8 Correct 2 ms 288 KB Output is correct
9 Correct 1 ms 288 KB Output is correct
10 Correct 2 ms 308 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 2 ms 312 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 208 KB Output is correct
15 Correct 2 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 308 KB Output is correct
8 Correct 2 ms 288 KB Output is correct
9 Correct 1 ms 288 KB Output is correct
10 Correct 2 ms 308 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 2 ms 312 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 208 KB Output is correct
15 Correct 2 ms 308 KB Output is correct
16 Correct 3 ms 432 KB Output is correct
17 Correct 9 ms 208 KB Output is correct
18 Correct 12 ms 316 KB Output is correct
19 Correct 11 ms 292 KB Output is correct
20 Correct 15 ms 308 KB Output is correct
21 Correct 15 ms 308 KB Output is correct
22 Correct 8 ms 316 KB Output is correct
23 Correct 19 ms 208 KB Output is correct
24 Correct 19 ms 300 KB Output is correct
25 Correct 23 ms 228 KB Output is correct
26 Correct 17 ms 304 KB Output is correct
27 Correct 19 ms 296 KB Output is correct
28 Correct 19 ms 208 KB Output is correct
29 Correct 17 ms 208 KB Output is correct
30 Correct 19 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 308 KB Output is correct
8 Correct 2 ms 288 KB Output is correct
9 Correct 1 ms 288 KB Output is correct
10 Correct 2 ms 308 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 2 ms 312 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 208 KB Output is correct
15 Correct 2 ms 308 KB Output is correct
16 Correct 3 ms 432 KB Output is correct
17 Correct 9 ms 208 KB Output is correct
18 Correct 12 ms 316 KB Output is correct
19 Correct 11 ms 292 KB Output is correct
20 Correct 15 ms 308 KB Output is correct
21 Correct 15 ms 308 KB Output is correct
22 Correct 8 ms 316 KB Output is correct
23 Correct 19 ms 208 KB Output is correct
24 Correct 19 ms 300 KB Output is correct
25 Correct 23 ms 228 KB Output is correct
26 Correct 17 ms 304 KB Output is correct
27 Correct 19 ms 296 KB Output is correct
28 Correct 19 ms 208 KB Output is correct
29 Correct 17 ms 208 KB Output is correct
30 Correct 19 ms 316 KB Output is correct
31 Correct 38 ms 292 KB Output is correct
32 Correct 54 ms 304 KB Output is correct
33 Correct 64 ms 304 KB Output is correct
34 Correct 71 ms 296 KB Output is correct
35 Correct 82 ms 436 KB Output is correct
36 Correct 111 ms 304 KB Output is correct
37 Correct 77 ms 328 KB Output is correct
38 Correct 88 ms 348 KB Output is correct
39 Correct 71 ms 404 KB Output is correct
40 Correct 98 ms 324 KB Output is correct
41 Correct 91 ms 324 KB Output is correct
42 Correct 38 ms 308 KB Output is correct
43 Correct 101 ms 316 KB Output is correct
44 Correct 94 ms 304 KB Output is correct
45 Correct 72 ms 308 KB Output is correct
46 Correct 81 ms 444 KB Output is correct
47 Correct 96 ms 332 KB Output is correct
48 Correct 87 ms 316 KB Output is correct
49 Correct 46 ms 436 KB Output is correct
50 Correct 85 ms 452 KB Output is correct
51 Correct 94 ms 320 KB Output is correct
52 Correct 89 ms 304 KB Output is correct
53 Correct 86 ms 432 KB Output is correct
54 Correct 41 ms 308 KB Output is correct
55 Correct 87 ms 292 KB Output is correct
56 Correct 70 ms 444 KB Output is correct
57 Correct 90 ms 328 KB Output is correct
58 Correct 98 ms 300 KB Output is correct
59 Correct 81 ms 320 KB Output is correct
60 Correct 90 ms 308 KB Output is correct