이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "messy.h"
//#include "Lgrader.cpp"
using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
int n;
void prec(int l, int r)
{
if(l == r)
return;
int mid = (l + r) >> 1;
for(int i = l; i <= mid; i++)
{
string s(::n, '0');
for(int j = l; j <= r; j++)
s[j] = '1';
s[i] = '0';
add_element(s);
}
prec(l, mid);
prec(mid + 1, r);
}
void get(int l, int r, vector<int> cands, vector<int> &ret)
{
if(l == r)
{
ret[l] = cands.back();
return;
}
vector<int> L, R;
int mid = (l + r) >> 1;
for(int i: cands)
{
string s(::n, '0');
for(int j: cands)
s[j] = '1';
s[i] = '0';
if(check_element(s))
L.push_back(i);
else
R.push_back(i);
}
assert(cands.size() == (r - l + 1));
get(l, mid, L, ret);
get(mid + 1, r, R, ret);
}
vector<int> restore_permutation(int n, int w, int r)
{
::n = n;
string tmp(n, '0');
prec(0, n - 1);
compile_set();
vector<int> ret(n, 0);
vector<int> cands(n, 0);
for(int i = 0; i < n; i++)
cands[i] = i;
get(0, n - 1, cands, ret);
return ret;
}
컴파일 시 표준 에러 (stderr) 메시지
In file included from /usr/include/c++/7/cassert:44:0,
from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
from messy.cpp:1:
messy.cpp: In function 'void get(int, int, std::vector<int>, std::vector<int>&)':
messy.cpp:57:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
assert(cands.size() == (r - l + 1));
~~~~~~~~~~~~~^~~~~~~~~~~~~~
# | 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... |