Submission #486310

#TimeUsernameProblemLanguageResultExecution timeMemory
486310MilosMilutinovicUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
//#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const ll mod2=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

/*
n=8
1000|0000
0100|0000
0010|0000
0001|0000



*/

int n;
VI ans;

void setup(int l,int r) {
	if (l>=r) return;
	string s=string(n,'1');
	rep(i,l,r+1) s[i]='0';
	int md=l+r>>1;
	rep(i,l,md+1) {
		s[i]='1';
		add_element(s);
		s[i]='0';
	}
}

void gao(int l,int r,VI v) {
	if (l>r) return;
	if (l==r) {
		//printf("::%d\n",SZ(v));
		ans[v[0]]=l;
		return;
	}
	string s=string(n,'1');
	rep(i,0,SZ(v)) s[v[i]]='0';
	int md=l+r>>1; VI left,right;
	rep(i,0,SZ(v)) {
		s[v[i]]='1';
		bool is=check_element(s);
		(is?left:right).pb(v[i]);
		s[v[i]]='0';
	}
	gao(l,md,left);
	gao(md+1,r,right);
}

VI restore_permutation(int N,int uselessW,int uselessR) {
	n=N;
	ans.resize(n);
	setup(0,n-1);
	compile_set();
	VI gas(n);
	iota(all(gas),0);
	gao(0,n-1,gas);
	return ans;
}

Compilation message (stderr)

messy.cpp: In function 'void setup(int, int)':
messy.cpp:42:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |  int md=l+r>>1;
      |         ~^~
messy.cpp:45:3: error: 'add_element' was not declared in this scope
   45 |   add_element(s);
      |   ^~~~~~~~~~~
messy.cpp: In function 'void gao(int, int, VI)':
messy.cpp:59:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   59 |  int md=l+r>>1; VI left,right;
      |         ~^~
messy.cpp:62:11: error: 'check_element' was not declared in this scope
   62 |   bool is=check_element(s);
      |           ^~~~~~~~~~~~~
messy.cpp: In function 'VI restore_permutation(int, int, int)':
messy.cpp:74:2: error: 'compile_set' was not declared in this scope
   74 |  compile_set();
      |  ^~~~~~~~~~~