답안 #577844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577844 2022-06-15T10:01:33 Z Markomafko972 Art Collections (BOI22_art) C++17
0 / 100
1 ms 592 KB
#include <bits/stdc++.h>

#include "art.h"

using namespace std;
void solve(int n) {
	vector<int> v[4005];
	int a[4005];
	for (int i = 0; i < n; i++) {
		v[i].clear();
		for (int j = 0; j < n; j++) {
			v[i].push_back((i+j)%n+1);
		}
		a[i] = publish(v[i]);
	}
	
	vector<int> sol;
	for (int i = n-1; i >= 1; i--) {
		int p = 0, da = 0;
		for (int j = 0; j < n; j++) {
			while (p < n && (p <= j || a[p] == -1)) p++;
			if (p >= n) break;
			if (a[j] == -1) continue;
			
			if (a[p]-a[j] == i) {
				a[j] = -1;
				sol.push_back(j+1);
				da = 1;
				
				int d = 1;
				while (j-d >= 0) {
					if (a[j-d] != -1) a[j-d] -= d;
					d++;
				}
				
				d = 1;
				while (j+d < n) {
					if (a[j+d] != -1) a[j+d] -= i-d+1;
					d++;
				}
				
				break;
			}
		}
		
		if (da == 0) {
			int poc = 0;
			while (a[poc] == -1) poc++;
			int kr = n-1;
			while (a[kr] == -1) kr--;
			
			if (a[poc]-a[kr] == i) {
				a[kr] = -1;
				sol.push_back(kr+1);
				
				for (int j = kr-1; j >= poc; j--) {
					if (a[j] != -1) a[j] -= kr-j;
				}
			}
			else assert(0);
		}
	}
	
	for (int i = 0; i < n; i++) {
		if (a[i] != -1) sol.push_back(i+1);
	}
	answer(sol);
}

Compilation message

interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -