이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// moreflags=grader.cpp
#include <vector>
// 15
// (somehow the wrong solution breaks at the sample solution... and I didn't notice it!?)
#include "messy.h"
#if not LOCAL
#define NDEBUG 1
#endif
#include<cassert>
template<bool write> std::vector<int> process(int n, std::vector<int> a, std::vector<int> pivot){
auto const sizea=(int)a.size();
auto const numBit=__builtin_ctz(sizea);
assert(sizea==(1<<numBit));
if(sizea==1) return a;
auto const half=sizea>>1;
if(write){
std::vector<int> first(a.begin(), a.begin()+half), sec(a.begin()+half, a.end());
for(auto it: first){
std::string tmp(n,'0');
for(auto it: pivot) tmp[it]='1';
tmp[it]='1';
add_element(std::move(tmp));
}
process<true>(n, first, sec);
process<true>(n, sec, first);
return {};
}else{
std::vector<int> first, sec;
for(auto it: a){
std::string tmp(n,'0');
for(auto it: pivot) tmp[it]='1';
tmp[it]='1';
if(check_element(std::move(tmp)))
first.push_back(it);
else
sec.push_back(it);
}
assert((int)first.size()==half);
assert((int)sec.size()==half);
auto result=process<false>(n, first, sec);
auto result2=process<false>(n, sec, first);
result.insert(result.end(),begin(result2), end(result2));
return result;
}
}
std::vector<int> restore_permutation(int n, int w, int r) {
std::vector<int> all(n);
for(int i=0; i<n; ++i) all[i]=i;
process<true>(n, all,{});
compile_set();
auto const result1=process<false>(n, std::move(all),{});
std::vector<int> result(n);
for(int index=0; index<n; ++index)
result[result1[index]]=index;
return result;
}
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In instantiation of 'std::vector<int> process(int, std::vector<int>, std::vector<int>) [with bool write = true]':
messy.cpp:55:25: required from here
messy.cpp:14:13: warning: unused variable 'numBit' [-Wunused-variable]
14 | auto const numBit=__builtin_ctz(sizea);
| ^~~~~~
messy.cpp: In instantiation of 'std::vector<int> process(int, std::vector<int>, std::vector<int>) [with bool write = false]':
messy.cpp:57:56: required from here
messy.cpp:14:13: warning: unused variable 'numBit' [-Wunused-variable]
# | 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... |