Submission #857992

# Submission time Handle Problem Language Result Execution time Memory
857992 2023-10-07T09:15:43 Z lovrot The Collection Game (BOI21_swaps) C++17
0 / 100
0 ms 344 KB
#include "swaps.h"
#include <cstdio> 
#include <algorithm> 
#include <vector> 

#define EB emplace_back
#define X first
#define Y second
#define MP make_pair

using namespace std;

typedef pair<int, int> pii;

void solve(int n, int v) {
	int log = 0, m = 1;
	vector<int> ANS;

	for(; (1 << log) < n; ++log) { m <<= 1; }
	for(int i = 0; i < m; ++i) ANS.EB(i < m - n ? -1 : i - m + n + 1);

	for(int i = 1 << 1; i <= m; i <<= 1) 
		for(int j = i >> 1; j; j >>= 1) {
			vector<pii> S;
			for(int k = m - n; k < m; ++k) {	
				int l = k ^ j;
				if(l > k) {
					if(k & i) swap(l, k);
					S.EB(MP(ANS[k], ANS[l]));
					schedule(ANS[k], ANS[l]);
//					if(k & i) S.EB(MP(ANS[l], ANS[k]));
//					else S.EB(MP(ANS[k], ANS[l])); 
				}
			}
			vector<int> RES = visit(); 
			for(int i = 0; i < RES.size(); ++i) 
				if(!RES[i])
					swap(ANS[S[i].X], ANS[S[i].Y]);
			S.clear();
		}
	for(int i = 0; i < n; ++i) ANS[i] = ANS[i + m - n];
	ANS.erase(ANS.begin() + n, ANS.end());
	answer(ANS);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for(int i = 0; i < RES.size(); ++i)
      |                   ~~^~~~~~~~~~~~
# 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 -
# 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 340 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Not correct
2 Halted 0 ms 0 KB -