Submission #996141

# Submission time Handle Problem Language Result Execution time Memory
996141 2024-06-10T08:14:40 Z anHiep Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

#define int long long;
// static int a[5000];

int a[5004];
int mp[5004][5004];

void solve(int n) {

	// int value = query(1, N);

	// for(int i = 1; i <= N; i++) {
	// 	answer(i, i);
	// }
	int dis = query(1,2);
	// map<pair<int,int>,int> mp;
	for(int i = 3; i <= n; i++){
		mp[i-1][i] = query(i-1, i);
		mp[i-2][i] = query(i-2, i);
	}
	for(int i = 1; i <= n; i++){
		a[1] = i;
		bool c = 1;
		if(i + dis <= n){
			c = 1;
			a[2] = i + dis;
			vector<int> used(n+1,0);
			used[a[1]] = 1;
			used[a[2]] = 2;

			for(int j = 3; j <= n; j++){
				int x = a[j-1] - mp[j-1][j];
				if(x >= 1 && used[x] == 0){
					if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[j-2][j]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[j-1][j])){
						a[j] = x;
						used[x] = j;
						continue;
					}
				}
				x = a[j-1] + mp[j-1][j];
				if(x <= n && used[x] == 0){
					if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[j-2][j]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[j-1][j])){
						a[j] = x;
						used[x] = j;
						continue;
					}
				}
				c = 0;
			}
			if(c){ 
				if(used[1]>used[n])continue;
				for(int j = 1;j<=n;j++){
					// cout<<a[j]<<" ";
					answer(j,a[j]);
				}
				// cout<<endl;
				return;
			}
		}
		if(i - dis >= 1){
			c = 1;
			a[2] = i - dis;
			vector<int> used(n+1,0);
			used[a[1]] = 1;
			used[a[2]] = 2;
			for(int j = 3;j<=n;j++){
				int x = a[j-1] - mp[j-1][j];
				if(x >= 1 && used[x] == 0){
					if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[j-2][j]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[j-1][j])){
						a[j] = x;
						used[x] = j;
						continue;
					}
				}
				x = a[j-1] + mp[j-1][j];
				if(x <= n && used[x] == 0){
					if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[j-2][j]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[j-1][j])){
						a[j] = x;
						used[x] = j;
						continue;
					}
				}
				c = 0;
			}
			if(c){
				if(used[1]>used[n]) continue;
				for(int j = 1;j<=n;j++){
					// cout<<a[j]<<" ";
					answer(j,a[j]);
				}
				// cout<<endl;
				return;
			}
		}
	}

}

Compilation message

xylophone.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
xylophone.cpp:9:1: note: in expansion of macro 'int'
    9 | int a[5004];
      | ^~~
xylophone.cpp:9:5: error: 'a' does not name a type
    9 | int a[5004];
      |     ^
xylophone.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
xylophone.cpp:10:1: note: in expansion of macro 'int'
   10 | int mp[5004][5004];
      | ^~~
xylophone.cpp:10:5: error: 'mp' does not name a type
   10 | int mp[5004][5004];
      |     ^~
xylophone.cpp:6:22: error: expected ')' before ';' token
    6 | #define int long long;
      |                      ^
xylophone.cpp:12:12: note: in expansion of macro 'int'
   12 | void solve(int n) {
      |            ^~~
xylophone.cpp:12:11: note: to match this '('
   12 | void solve(int n) {
      |           ^
xylophone.cpp:12:16: error: 'n' does not name a type; did you mean 'yn'?
   12 | void solve(int n) {
      |                ^
      |                yn