Submission #640052

# Submission time Handle Problem Language Result Execution time Memory
640052 2022-09-13T11:58:40 Z jasmin The Collection Game (BOI21_swaps) C++14
35 / 100
102 ms 520 KB
#include <swaps.h>
#include<cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
using namespace std;
 
/*void schedule(int i, int j){
    cout << "schedule " << i << " " << j << "\n" << flush;
}
 
vector<int> visit(){
    cout << "visit\n" << flush;
    int n;
    cin >> n;
    vector<int> ans(n);
    for(int i=0; i<n; i++){
        cin >> ans[i];
    }
    cout << "Yes: " << n << "\n";
    return ans;
}
 
void answer(vector<int>& ans){
    cout << "answer: \n";
    for(auto e: ans){
        cout << e << " ";
    }
    cout << "\n" << flush;
}*/
 
void solve(int n, int v){
	vector<vector<int> > op(n);
	for(int i=0; i<n; i++){
		op[0].push_back(i+1);
	}
 
	int q=0;
	while(true){
 
		int cnt=0;
		for(int j=0; j<n; j++){
			for(int k=0; k+1<(int)op[j].size(); k+=2){
				schedule(op[j][k], op[j][k+1]);
				cnt++;
			}
		}
		
		if(cnt==0) break;
		
		if(q==v) answer({1, 2, 3});
 
		vector<int> resp=visit();
		q++;
		int ind=0;
		vector<vector<int> > op2(n);
		for(int j=0; j<n; j++){
			for(int k=0; k+1<(int)op[j].size(); k+=2){
				if(resp[ind]){
					op2[j].push_back(op[j][k]);
					op2[j+1].push_back(op[j][k+1]);
				}
				else{
					op2[j+1].push_back(op[j][k]);
					op2[j].push_back(op[j][k+1]);
				}
				ind++;
			}
			if(op[j].size()%2==1){
				op2[j].push_back(op[j][op[j].size()-1]);
			}
		}
		op=op2;
	}
  	
  	vector<int> ans(n);
  	for(int i=0; i<n; i++){
  		assert(op[i].size()==1);
    	ans[i]=op[i][0];
    }
  	answer(ans);
}
 
/*signed main(){
	int n, v;
	cin >> n >> v;
	solve(n, v);
}*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 6 ms 312 KB Correct
3 Correct 20 ms 324 KB Correct
4 Correct 63 ms 368 KB Correct
5 Correct 71 ms 356 KB Correct
6 Correct 67 ms 344 KB Correct
7 Correct 71 ms 440 KB Correct
8 Correct 67 ms 356 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 17 ms 324 KB Correct
4 Correct 76 ms 352 KB Correct
5 Correct 67 ms 356 KB Correct
6 Correct 74 ms 460 KB Correct
7 Correct 64 ms 372 KB Correct
8 Correct 70 ms 372 KB Correct
9 Correct 66 ms 352 KB Correct
10 Correct 68 ms 360 KB Correct
11 Correct 71 ms 520 KB Correct
12 Correct 79 ms 404 KB Correct
13 Correct 66 ms 384 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Correct
2 Correct 7 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Correct
2 Correct 7 ms 316 KB Correct
3 Correct 0 ms 208 KB Correct
4 Correct 4 ms 308 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 5 ms 208 KB Correct
3 Correct 22 ms 336 KB Correct
4 Correct 68 ms 516 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 5 ms 208 KB Correct
3 Correct 22 ms 336 KB Correct
4 Correct 68 ms 516 KB Correct
5 Correct 1 ms 208 KB Correct
6 Correct 4 ms 304 KB Correct
7 Correct 18 ms 332 KB Correct
8 Correct 85 ms 456 KB Correct
9 Correct 64 ms 508 KB Correct
10 Correct 67 ms 416 KB Correct
11 Correct 66 ms 476 KB Correct
12 Correct 78 ms 356 KB Correct
13 Correct 0 ms 208 KB Correct
14 Correct 5 ms 208 KB Correct
15 Correct 19 ms 312 KB Correct
16 Correct 71 ms 392 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 6 ms 208 KB Correct
3 Correct 20 ms 320 KB Correct
4 Correct 69 ms 400 KB Correct
5 Incorrect 46 ms 348 KB Not correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 6 ms 208 KB Correct
3 Correct 20 ms 320 KB Correct
4 Correct 69 ms 400 KB Correct
5 Incorrect 46 ms 348 KB Not correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 6 ms 312 KB Correct
3 Correct 28 ms 328 KB Correct
4 Correct 102 ms 404 KB Correct
5 Incorrect 52 ms 324 KB Not correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 6 ms 312 KB Correct
3 Correct 28 ms 328 KB Correct
4 Correct 102 ms 404 KB Correct
5 Incorrect 52 ms 324 KB Not correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 5 ms 312 KB Correct
3 Correct 21 ms 324 KB Correct
4 Correct 75 ms 400 KB Correct
5 Incorrect 41 ms 368 KB Not correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 5 ms 312 KB Correct
3 Correct 21 ms 324 KB Correct
4 Correct 75 ms 400 KB Correct
5 Incorrect 41 ms 368 KB Not correct
6 Halted 0 ms 0 KB -