이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//I love armpit fetish
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';
#define PR0(A, n) cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';
#define FILE_NAME ""
void add(int l, int r, int n) {
if (l==r)
return;
string s;
for (int i=0; i<n; ++i)
s += '0';
int mid = (l+r)/2;
for (int i=l; i<=r; ++i)
s[i] = '1';
for (int i=l; i<=mid; ++i) {
s[i] = '0';
//cerr << s << '\n';
add_element(s);
s[i] = '1';
}
add(l, mid, n);
add(mid+1, r, n);
}
void Find(int l, int r, int n, vector<int> p, vector<int> &res) {
if (l==r) {
res[p[0]] = l;
return;
}
string s;
vector<int> p1, p2;
for (int i=0; i<n; ++i)
s += '0';
for (int i=0; i<p.size(); ++i)
s[p[i]] = '1';
for (int i=0; i<p.size(); ++i) {
//cerr << p[i] << '\n';
s[p[i]] = '0';
//cerr << s << '\n';
if (check_element(s))
p1.push_back(p[i]);
else
p2.push_back(p[i]);
s[p[i]] = '1';
}
int mid = (l + r) / 2;
Find(l, mid, n, p1, res);
Find(mid+1, r, n, p2, res);
}
vector<int> restore_permutation(int n, int w, int r) {
add(0, n-1, n);
compile_set();
vector<int> p, res(n);
for (int i=0; i<n; ++i)
p.push_back(i);
Find(0, n-1, n, p, res);
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void Find(int, int, int, std::vector<int>, std::vector<int>&)':
messy.cpp:41:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<p.size(); ++i)
~^~~~~~~~~
messy.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<p.size(); ++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... |