답안 #850903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850903 2023-09-17T18:13:40 Z vjudge1 Xylophone (JOI18_xylophone) C++17
0 / 100
0 ms 444 KB
#include <bits/stdc++.h>
#define all(v) ((v).begin(),(v).end())
#define ll long long
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll mxN = 1e5 + 2;
using namespace std;
static const int N_MAX = 5000;
static const int Q_MAX = 10000;
static int N;
static int A[N_MAX];
static bool used[N_MAX];
static int query_c;
static int answer_c;

int query(int s, int t);
// 	if(query_c >= Q_MAX) {
// 		printf("Wrong Answer\n");
// 		exit(0);
// 	}
// 	query_c++;
// 	if(!(1 <= s && s <= t && t <= N)) {
// 		printf("Wrong Answer\n");
// 		exit(0);
// 	}
// 	int mx = 0, mn = N + 1;
// 	for(int i = s - 1; i < t; i++) {
// 		if(mx < A[i]) {
// 			mx = A[i];
// 		}
// 		if(mn > A[i]) {
// 			mn = A[i];
// 		}
// 	}
// 	return mx - mn;
// }

void answer(int i, int a);
// 	answer_c++;
// 	if(!(1 <= i && i <= N)) {
// 		printf("Wrong Answer\n");
// 		exit(0);
// 	}
// 	if(!(1 <= a && a <= N)) {
// 		printf("Wrong Answer\n");
// 		exit(0);
// 	}
// 	if(used[i - 1]) {
// 		printf("Wrong Answer\n");
// 		exit(0);
// 	}
// 	if(a != A[i - 1]) {
// 		printf("Wrong Answer\n");
// 		exit(0);
// 	}
// 	used[i - 1] = true;
// }
int ans[N_MAX];
int id[N_MAX];
void ass(int x,int i){
	answer(i,x);
	ans[i] = x;
	id[x] = i;
}
void solve(int N) {
	int i = 1,j = N;
	while(i != j){
		if(id[1] && id[N] ) break;
		if(!id[1] && query(i + 1,j) != N - 1) ass(1,i);
		else if(!id[1])i++;
		if(!id[N] && query(i,j - 1) != N - 1) ass(N,j);
		else if(!id[N])j--;
		// cout<<id[N]<<' '<<id[1]<<' '<<i<<' '<<j<<'\n';
	}
	int prev = -1;
	for(int i = id[N] + 1;i <= N;i++){
		int x = N - query(id[N],i);
		if(x != prev) {
			ass(x,i);
			prev = x;
		}
	}
	for(int i = id[N] + 1;i <= N;i++){
		if(!ans[i]){
			int x = ans[i - 1] + query(i - 1,i);
			ass(x,i);
		}
	}
	prev = -1;
	for(int i = id[1] - 1;i;i--){
		int x = 1 + query(i,id[1]);
		if(x != prev){
			ass(x,i);
			prev = x;
		}
	}
	for(int i = id[1] - 1;i;i--){
		if(!ans[i]){
			int x = ans[i + 1] - query(i, i + 1);
			ass(x, i);
		}
	}
	prev = -1;
	for(int i = id[N] - 1;i > id[1];i--){
		int x = N - query(i,id[N]);
		if(x != prev){
			ass(x,i);
			prev = x;
		}
	}
	for(int i = id[N] - 1;i > id[1];i--){
		if(!ans[i]){
			int x = ans[i + 1] + query(i, i + 1);
			ass(x, i);
		}
	}
	// for(int i = 1;i <= N;i++) cout<<ans[i]<<' ';
	// cout<<'\n';
}

// int main() {
// 	query_c = 0;
// 	answer_c = 0;
// 	if(scanf("%d", &N) != 1) {
// 		fprintf(stderr, "Error while reading input\n");
// 		exit(1);
// 	}
// 	for(int i = 0; i < N; i++) {
// 		if(scanf("%d", A + i) != 1) {
// 			fprintf(stderr, "Error while reading input\n");
// 			exit(1);
// 		}
// 		used[i] = false;
// 	}
// 	solve(N);
// 	if(!(answer_c == N)) {
// 		printf("Wrong Answer\n");
// 		exit(0);
// 	}
// 	printf("Accepted : %d\n", query_c);
// }

Compilation message

xylophone.cpp:15:12: warning: 'answer_c' defined but not used [-Wunused-variable]
   15 | static int answer_c;
      |            ^~~~~~~~
xylophone.cpp:14:12: warning: 'query_c' defined but not used [-Wunused-variable]
   14 | static int query_c;
      |            ^~~~~~~
xylophone.cpp:13:13: warning: 'used' defined but not used [-Wunused-variable]
   13 | static bool used[N_MAX];
      |             ^~~~
xylophone.cpp:12:12: warning: 'A' defined but not used [-Wunused-variable]
   12 | static int A[N_MAX];
      |            ^
xylophone.cpp:11:12: warning: 'N' defined but not used [-Wunused-variable]
   11 | static int N;
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 444 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Incorrect 0 ms 440 KB Wrong Answer [4]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 444 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Incorrect 0 ms 440 KB Wrong Answer [4]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 444 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Incorrect 0 ms 440 KB Wrong Answer [4]
4 Halted 0 ms 0 KB -