답안 #74327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74327 2018-08-31T10:09:02 Z Mamnoon_Siam Xylophone (JOI18_xylophone) C++17
0 / 100
2 ms 248 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

void solve(int N) {
	if(N == 2) {
		answer(0, 0);
		answer(1, 1);
		return;
	}
	vector<int> a(N), two(N), three(N);
	for(int i = 0; i < N - 1; i++) {
		two[i] = query(i, i + 1);
		if(i < N - 2) three[i] = query(i, i + 2);
	}
	a[1] = two[0];
	int tog = 1;
	for(int i = 2; i < N; i++) {
		if(three[i - 2] == two[i - 2] + two[i - 1]) {
			a[i] = tog ? a[i - 1] + two[i - 1] : a[i - 1] - two[i - 1];
		} else {
			a[i] = tog ? a[i - 1] - two[i - 1] : a[i - 1] + two[i - 1];
			tog ^= 1;
		}
	}
	int mxid, mnid, mx = -1e5, mn = 1e5;
	for(int i = 0; i < N; i++) {
		if(a[i] < mn) mn = a[i], mnid = i;
		if(a[i] > mx) mx = a[i], mxid = i;
	}
	if(mxid < mnid) {
		for(int &b : a) b = -b;
		swap(mn, mx);
		mx = -mx, mn = -mn;
	}
	for(int i = 0; i < N; i++) a[i] -= mn;
	for(int i = 0; i < N; i++) answer(i, a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:31:2: warning: 'mxid' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(mxid < mnid) {
  ^~
xylophone.cpp:31:2: warning: 'mnid' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -