제출 #551801

#제출 시각아이디문제언어결과실행 시간메모리
551801QwertyPiXylophone (JOI18_xylophone)C++14
0 / 100
3 ms312 KiB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
static int A[5000];
int d[5000], dd[5001], sg[5001];
void solve(int N) {
	for(int i = 1; i <= N - 1; i++){
		d[i] = query(i, i + 1);
	}
	sg[1] = 1;
	int cur_val = d[1];
	for(int i = 2; i <= N - 1; i++){
		int val = query(i - 1, i + 1);
		sg[i] = (abs(d[i - 1] + d[i]) == val ? 1 : -1) * sg[i - 1];
	}
	A[1] = 1;
	for(int i = 2; i <= N; i++){
		A[i] = A[i - 1] + d[i - 1] * sg[i - 1];
	}
	
	int mn = N + 1;
	for(int i = 1; i <= N; i++){
		mn = min(A[i], mn);
	}
	for(int i = 1; i <= N; i++){
		A[i] += 1 - mn;
	}
	
	if(A[1] > A[N]){
		for(int i = 1; i <= N; i++){
			A[i] = N + 1 - A[i];
		}
	}

	for(int i = 1; i <= N; i++) {
		answer(i, A[i]);
	}

}

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:11:6: warning: unused variable 'cur_val' [-Wunused-variable]
   11 |  int cur_val = d[1];
      |      ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...