Submission #922383

# Submission time Handle Problem Language Result Execution time Memory
922383 2024-02-05T12:59:33 Z ByeWorld Unscrambling a Messy Bug (IOI16_messy) C++14
38 / 100
1 ms 600 KB
#include <vector>
#include <bits/stdc++.h>
#define bupol __builtin_popcount
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
const int MAXN = 1e3+5;
const int MAXK = 205;
const int LOG = 20;
const int MOD = 1e9+7;
const int SQRT = 520;
const ll INF = 1e18+10;
typedef pair<int,int> pii;
typedef pair<pii,int> ipii;
#include "messy.h"

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, R, cnt;
vector <int> vec, perm;
void ADD(){
	string s = "";
	for(int i=0; i<n; i++) s += '1';
	//add_element(s);
	for(int i=n-1; i>=1; i--){
		s[i] = '0';
		//cout << s << " oo\n";
		add_element(s);
	}
}
void CHECK(){
	assert(cnt <= R);
	string s;
	for(int i=0; i<n; i++) s += '0';
	for(int i=0; i<n; i++){ // check yg i (0)
		perm.clear();
		for(int j=0; j<n; j++){
			if(vec[j] != -1) continue;
			perm.pb(j);
		}

		shuffle(perm.begin(), perm.end(), rng);
		for(int j=0; j<perm.size(); j++){ // j='1', i+1->n-1 = '0'
			s[perm[j]] = '1';
			//cout << s << " p\n";
			if(check_element(s)){
				cnt++;
				//cout << s << ' ' << j << ' ' << i << " xx\n";
				vec[perm[j]] = i;
				break;
			} else {
				s[perm[j]] = '0';
			}
		}
	}
}

vector<int> restore_permutation(int N, int w, int r) {
	n = N; vec.resize(n); R = r;
	for(int i=0; i<n; i++) vec[i] = -1;

	ADD();
    compile_set();
    CHECK();

    for(int i=0; i<n; i++)
    	if(vec[i]==-1) vec[i] = n-1;

    return vec;
}

Compilation message

messy.cpp: In function 'void CHECK()':
messy.cpp:48:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for(int j=0; j<perm.size(); j++){ // j='1', i+1->n-1 = '0'
      |                ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 8
2 Correct 1 ms 348 KB n = 8
3 Correct 0 ms 348 KB n = 8
4 Correct 1 ms 600 KB n = 8
5 Correct 0 ms 348 KB n = 8
6 Correct 0 ms 348 KB n = 8
7 Correct 0 ms 348 KB n = 8
8 Correct 0 ms 348 KB n = 8
9 Correct 1 ms 348 KB n = 8
10 Correct 0 ms 348 KB n = 8
11 Correct 1 ms 348 KB n = 8
12 Correct 0 ms 348 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 0 ms 348 KB n = 8
15 Correct 0 ms 348 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 32
2 Correct 0 ms 348 KB n = 32
3 Correct 1 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 0 ms 344 KB n = 32
6 Correct 0 ms 344 KB n = 32
7 Correct 1 ms 348 KB n = 32
8 Correct 0 ms 348 KB n = 32
9 Correct 0 ms 348 KB n = 32
10 Correct 0 ms 348 KB n = 32
11 Correct 0 ms 348 KB n = 32
12 Correct 0 ms 348 KB n = 32
13 Correct 1 ms 344 KB n = 32
14 Correct 0 ms 344 KB n = 32
15 Correct 0 ms 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 32
2 Correct 0 ms 344 KB n = 32
3 Correct 0 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 0 ms 436 KB n = 32
6 Correct 1 ms 348 KB n = 32
7 Incorrect 0 ms 348 KB grader returned WA
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -