이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <cstdlib>
#include <iostream>
#include "messy.h"
#include <numeric>
#include <algorithm>
#include <random>
#include <chrono>
using namespace std;
vector<int> ans;
void prec(vector<int> in, vector<int> out){
if(in.size() % 2) return;
string s = string(in.size() + out.size(), '0');
vector<int> l, r, ll = out, rr = out;
for(int i : out){
s[i] = '1';
}
for(int i = 0; i < in.size()/2; i ++){
s[in[i]] = '1';
l.push_back(in[i]);
r.push_back(in[i+in.size()/2]);
ll.push_back(in[i]);
rr.push_back(in[i+in.size()/2]);
add_element(s);
s[in[i]] = '0';
}
prec(l, rr);
prec(r, ll);
}
void comp(vector<int> in, vector<int> out, int L){
if(in.size() % 2){
ans[in[0]] = L;
return;
}
string s = string(in.size() + out.size(), '0');
for(int i : out){
s[i] = '1';
}
vector<int> l, r, ll = out, rr = out;
for(int i : in){
s[i] = '1';
if(check_element(s)){
l.push_back(i);
ll.push_back(i);
}
else{
r.push_back(i);
rr.push_back(i);
}
s[i] = '0';
}
comp(l, rr, L);
comp(r, ll, L + in.size() / 2);
}
vector<int> restore_permutation(int N, int W, int R){
vector<int> arr(N), brr;
iota(arr.begin(), arr.end(), 0);
prec(arr, brr);
compile_set();
ans.resize(N);
comp(arr, brr, 0);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void prec(std::vector<int>, std::vector<int>)':
messy.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i = 0; i < in.size()/2; i ++){
| ~~^~~~~~~~~~~~~
# | 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... |