Submission #970442

# Submission time Handle Problem Language Result Execution time Memory
970442 2024-04-26T14:16:59 Z NotLinux The Collection Game (BOI21_swaps) C++17
5 / 100
46 ms 2072 KB
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
//     swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include <bits/stdc++.h>
#include "swaps.h"
using namespace std;
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
void solve(int N , int V) {
	vector < int > v(N),ans;
	iota(all(v),1);
	map < pair < int , int > , bool > memo;
	while(sz(v)){
		vector < int > curv = v , newv;
		while(sz(curv) > 1){
			newv.clear();
			vector < int > with_schedule , with_memo;
			for(int i = 0;i<(sz(curv)-1);i+=2){
				if(memo.count({curv[i] , curv[i+1]})){
					with_memo.push_back(i);
				}
				else {
					with_schedule.push_back(i);
					schedule(curv[i] , curv[i+1]);
				}
			}
			vector < int > res = visit();
			for(auto itr : with_memo){
				newv.push_back(curv[itr + memo[{curv[itr] , curv[itr+1]}]]);
			}			
			for(int i = 0;i<sz(res);i++){
				newv.push_back(curv[with_schedule[i] + res[i]]);
				memo[{curv[with_schedule[i]] , curv[with_schedule[i] + 1]}] = res[i];
			}
			if(sz(curv) & 1){
				newv.push_back(curv.back());
			}
			curv = newv;
			// cout << "	curv : ";for(auto itr : curv)cout << itr << " ";cout << endl;
		}
		ans.push_back(curv[0]);
		v.erase(find(all(v) , curv[0]));
		// cout << "v : ";for(auto itr : v)cout << itr << " ";cout << endl;
		// cout << "ans : ";for(auto itr : ans)cout << itr << " ";cout << endl;
		// cout << endl;
	}
	reverse(all(ans));
	answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 4 ms 980 KB Correct
3 Correct 15 ms 1436 KB Correct
4 Correct 44 ms 1136 KB Correct
5 Correct 26 ms 1040 KB Correct
6 Correct 32 ms 1672 KB Correct
7 Correct 43 ms 1624 KB Correct
8 Correct 41 ms 1496 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Correct
2 Correct 3 ms 472 KB Correct
3 Correct 13 ms 1388 KB Correct
4 Correct 46 ms 1764 KB Correct
5 Correct 34 ms 1252 KB Correct
6 Correct 33 ms 1644 KB Correct
7 Correct 40 ms 2072 KB Correct
8 Correct 40 ms 1704 KB Correct
9 Runtime error 13 ms 1144 KB Execution killed with signal 13
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Not correct
2 Halted 0 ms 0 KB -