이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
#define ll int
#define F first
#define S second
#define sz(x) (ll)x.size()
#define pb push_back
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i= 0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
vi restore_permutation(int n, int w, int r) {
string s;
for (ll i =0; i<n; i++) s.pb('0');
for (ll i =0; i<n-1; i++){
s[i] = '1';
add_element(s);
}
compile_set();
vector <string> vs(n-1);
ll n2 = (1<<n);
for (ll i =0; i<n2; i++){
string c = s;
ll cnt = 0;
for (ll j =0; j<n; j++){
if (i & (1 << j)){
c[j] = '1';
cnt++;
}
else{
c[j] = '0';
}
}
bool x = check_element(c);
if (x){
vs[cnt-1] = c;
}
}
vi ans(n);
vi vis(n);
for (ll i =0; i<n-1; i++){
string c = vs[i];
ll init_pos = i, final_pos = -1;
for (ll j =0; j<n; j++){
if (c[j] == '1' && !vis[j]){
final_pos = j;
break;
}
}
// dbg2(init_pos, final_pos);
vis[final_pos] = 1;
ans[final_pos] = init_pos;
}
for (ll i=0; i<n; i++){
if (!vis[i]){
ans[i] = n-1;
break;
}
}
return ans;
}
/*
4 16 16
2 1 3 0
8 256 256
2 1 3 4 7 0 6 5
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |