Submission #860880

# Submission time Handle Problem Language Result Execution time Memory
860880 2023-10-14T17:38:15 Z EntityPlantt Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int a[500];
void solve(int n) {
	a[2] = query(1, 2);
	for (int i = 2; i < n; i++) {
		int x = query(i, i + 1), y = query(i - 1, i + 1);
		a[i + 1] = a[i] + x * (a[i] - a[i - 1] < 0 ? 1 : -1) * (y == x + abs(a[i] - a[i - 1]) ? -1 : 1);
	}
	int mn = *min_element(a + 1, a + n + 1);
	int u, v;
	for(int i = 1; i <= n; ++i) {
		a[i] -= mn;
		if(a[i] == 0) u = i;
		if(a[i] == n - 1) v = i;
	}
	bool flag = u < v;
	for (int i = 1; i <= n; ++i) answer(i, flag ? a[i] + 1 : n - a[i]);
	return 0;
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:9: error: return-statement with a value, in function returning 'void' [-fpermissive]
   20 |  return 0;
      |         ^