제출 #702850

#제출 시각아이디문제언어결과실행 시간메모리
702850kxdXylophone (JOI18_xylophone)C++17
100 / 100
117 ms684 KiB
#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]);
	}
	int pos1, posn;
	forn1(i,n) {
		a[i] += 1 - min_;
		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]);
}

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:55:2: warning: 'posn' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |  if(pos1 > posn) {
      |  ^~
xylophone.cpp:55:2: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...