답안 #573038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
573038 2022-06-05T16:34:05 Z StrawHatWess Art Collections (BOI22_art) C++17
35 / 100
185 ms 296 KB
#include "art.h"

#include <bits/stdc++.h>
using namespace std;

typedef vector<int>vi; 
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define FOR(i,a,b) for(int i=a; i<b; i++)


//------------------------------

const int MX=1e5; 

int N; 

int cmp(int i, int j){
	vi vec={i,j}; 
	FOR(k,1,N+1) if(k!=i && k!=j) vec.pb(k); 

	int x=publish(vec); 
	swap(vec[0],vec[1]); 
	int y=publish(vec); 

	return (y>x); 
}

vi solve(vi vec){
	int n=sz(vec); 

	if(n<=1) return vec; 

	int m=(n-1)/2; 

	vi l,r; 
	FOR(i,0,n){
		if(i<=m) l.pb(vec[i]); 
		else r.pb(vec[i]); 
	}

	l=solve(l); 
	r=solve(r); 

	vi ans; 
	int i=0, j=0; 
	while(i<sz(l) || j<sz(r)){
		if(i<sz(l) && j<sz(r)){
			if(cmp(l[i],r[j])) ans.pb(l[i]), i++; 
			else ans.pb(r[j]), j++; 
		}
		else if(i<sz(l)) ans.pb(l[i]), i++; 
		else ans.pb(r[j]), j++; 
	}

	return ans;
}

void solve(int N){
	::N=N; 
	vi vec(N); iota(all(vec),1);  
	vec=solve(vec);
	answer(vec); 
}

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 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 220 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 220 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 5 ms 236 KB Output is correct
26 Correct 61 ms 208 KB Output is correct
27 Correct 60 ms 208 KB Output is correct
28 Correct 100 ms 284 KB Output is correct
29 Correct 108 ms 208 KB Output is correct
30 Correct 119 ms 288 KB Output is correct
31 Correct 98 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 2 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 220 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 5 ms 236 KB Output is correct
26 Correct 61 ms 208 KB Output is correct
27 Correct 60 ms 208 KB Output is correct
28 Correct 100 ms 284 KB Output is correct
29 Correct 108 ms 208 KB Output is correct
30 Correct 119 ms 288 KB Output is correct
31 Correct 98 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 2 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 4 ms 208 KB Output is correct
42 Correct 4 ms 208 KB Output is correct
43 Correct 4 ms 208 KB Output is correct
44 Correct 5 ms 208 KB Output is correct
45 Correct 64 ms 208 KB Output is correct
46 Correct 58 ms 208 KB Output is correct
47 Correct 106 ms 288 KB Output is correct
48 Correct 98 ms 296 KB Output is correct
49 Correct 123 ms 208 KB Output is correct
50 Correct 107 ms 288 KB Output is correct
51 Correct 1 ms 208 KB Output is correct
52 Incorrect 185 ms 208 KB Not correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 220 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 5 ms 236 KB Output is correct
26 Correct 61 ms 208 KB Output is correct
27 Correct 60 ms 208 KB Output is correct
28 Correct 100 ms 284 KB Output is correct
29 Correct 108 ms 208 KB Output is correct
30 Correct 119 ms 288 KB Output is correct
31 Correct 98 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 2 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 4 ms 208 KB Output is correct
42 Correct 4 ms 208 KB Output is correct
43 Correct 4 ms 208 KB Output is correct
44 Correct 5 ms 208 KB Output is correct
45 Correct 64 ms 208 KB Output is correct
46 Correct 58 ms 208 KB Output is correct
47 Correct 106 ms 288 KB Output is correct
48 Correct 98 ms 296 KB Output is correct
49 Correct 123 ms 208 KB Output is correct
50 Correct 107 ms 288 KB Output is correct
51 Correct 1 ms 208 KB Output is correct
52 Incorrect 185 ms 208 KB Not correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 220 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 5 ms 236 KB Output is correct
26 Correct 61 ms 208 KB Output is correct
27 Correct 60 ms 208 KB Output is correct
28 Correct 100 ms 284 KB Output is correct
29 Correct 108 ms 208 KB Output is correct
30 Correct 119 ms 288 KB Output is correct
31 Correct 98 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 2 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 4 ms 208 KB Output is correct
42 Correct 4 ms 208 KB Output is correct
43 Correct 4 ms 208 KB Output is correct
44 Correct 5 ms 208 KB Output is correct
45 Correct 64 ms 208 KB Output is correct
46 Correct 58 ms 208 KB Output is correct
47 Correct 106 ms 288 KB Output is correct
48 Correct 98 ms 296 KB Output is correct
49 Correct 123 ms 208 KB Output is correct
50 Correct 107 ms 288 KB Output is correct
51 Correct 1 ms 208 KB Output is correct
52 Incorrect 185 ms 208 KB Not correct
53 Halted 0 ms 0 KB -