이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#define pb push_back
using namespace std;
vector<int> ans;
int N;
void go(int l, int r, string s) {
if(l == r) return;
int mid = (l + r) / 2;
for(int i = l; i <= mid; i++) {
s[i] = '1';
add_element(s);
s[i] = '0';
}
for(int i = l; i <= mid; i++) {
s[i] = '1';
}
go(mid + 1, r, s);
for(int i = l; i <= r; i++) {
s[i] = '1' + '0' - s[i];
}
go(l, mid, s);
}
void find(int l, int r, vector<int> x) {
string s(N, '0');
for(int i = 0; i < x.size(); i++) {
s[x[i]] = '1';
}
if(l == r) {
for(int i = 0; i < x.size(); i++) {
if(s[i] == '1') continue;
ans[i] = l;
return;
}
}
vector<int> y, z;
for(int i = 0; i < N; i++) {
if(s[i] == '1') continue;
s[i] = '1';
if(check_element(s)) y.pb(i);
else z.pb(i);
s[i] = '0';
}
int mid = (l + r) / 2;
for(int i = 0; i < y.size(); i++) x.pb(y[i]);
find(mid + 1, r, x);
for(int i = 0; i < y.size(); i++) x.pop_back();
for(int i = 0; i < z.size(); i++) x.pb(z[i]);
find(l, mid, x);
}
vector<int> restore_permutation(int n, int w, int r) {
N = n;
string s(n, '0');
vector<int> x;
go(0, n - 1, s);
compile_set();
find(0, n - 1, x);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void find(int, int, std::vector<int>)':
messy.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 0; i < x.size(); i++) {
| ~~^~~~~~~~~~
messy.cpp:50:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i = 0; i < x.size(); i++) {
| ~~^~~~~~~~~~
messy.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int i = 0; i < y.size(); i++) x.pb(y[i]);
| ~~^~~~~~~~~~
messy.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int i = 0; i < y.size(); i++) x.pop_back();
| ~~^~~~~~~~~~
messy.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for(int i = 0; i < z.size(); i++) x.pb(z[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... |