이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> ans;
void addStuff(int start, int stop, int flagStart, int flagStop) {
for (int i=start;i<(start+stop)/2;i++) {
string s = "";
for (int j=0;j<N;j++) {
if (j == i || (flagStart <= j && j < flagStop)) {
s += "1";
} else {
s += "0";
}
}
add_element(s);
}
if (stop - start > 2) {
addStuff(start, (start+stop)/2, (start+stop)/2, stop);
addStuff((start+stop)/2, stop, start, (start+stop)/2);
}
}
void checkStuff(int start, int stop, vector<int>& flags, vector<int>& candidates) {
vector<int> zeroFlags, oneFlags;
string s = "";
for (int i=0;i<N;i++) s += "0";
for (int i=0;i<flags.size();i++) s[flags[i]] = '1';
for (int i=0;i<candidates.size();i++) {
string q = s;
q[candidates[i]] = '1';
if (check_element(q)) {
oneFlags.push_back(candidates[i]);
} else {
zeroFlags.push_back(candidates[i]);
}
}
if (stop - start > 2) {
checkStuff(start, (start+stop)/2, zeroFlags, oneFlags);
checkStuff((start+stop)/2, stop, oneFlags, zeroFlags);
} else {
ans[oneFlags[0]] = start;
ans[zeroFlags[0]] = start + 1;
}
}
vector<int> restore_permutation(int _n, int w, int r) {
N = _n;
addStuff(0, N, -1, -1);
compile_set();
ans.resize(N);
vector<int> x;
vector<int> all;
all.resize(N);
for (int i=0;i<N;i++) all[i] = i;
checkStuff(0, N, x, all);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void checkStuff(int, int, std::vector<int>&, std::vector<int>&)':
messy.cpp:27:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<flags.size();i++) s[flags[i]] = '1';
~^~~~~~~~~~~~~
messy.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<candidates.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... |