이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifndef hwe
#include "messy.h"
#endif
#include <bits/stdc++.h>
using namespace std;
#define popcount(n) (__builtin_popcountll((n)))
#define clz(n) (__builtin_clzll((n)))
#define ctz(n) (__builtin_ctzll((n)))
#define lg(n) (63 - __builtin_clzll((n)))
#define BIT(n, i) (((n) >> (i)) & 1ll)
#define MASK(i) (1ll << (i))
#define FLIP(n, i) ((n) ^ (1ll << (i)))
#define ON(n, i) ((n) | MASK(i))
#define OFF(n, i) ((n) & ~MASK(i))
#define Int __int128
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vll;
typedef vector<pair<long long, int>> vli;
typedef vector<pair<int, long long>> vil;
template <class T1, class T2>
bool maximize(T1 &x, T2 y) {
if (x < y) {
x = y;
return true;
}
return false;
}
template <class T1, class T2>
bool minimize(T1 &x, T2 y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <class T>
void remove_duplicate(vector<T> &ve) {
sort (ve.begin(), ve.end());
ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <class T> T random(T l, T r) {
return uniform_int_distribution<T>(l, r)(rng);
}
template <class T> T random(T r) {
return rng() % r;
}
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
vector<int> ans;
#ifdef hwe
void add_element(string a) {
cerr << "Add: " << a << '\n';
}
void compile_set() {
}
bool check_element(string x) {
cerr << "Check: " << x << '\n';
bool ret; cin >> ret; return ret;
}
#endif
void add(int l, int r, string s) {
int mid = l + r >> 1;
for (int i = l; i <= mid; ++i) {
s[i] = '1'; add_element(s); s[i] = '0';
}
if (l == r) return;
string le = s, ri = s;
for (int i = mid + 1; i <= r; ++i) le[i] = '1';
for (int i = l; i <= mid; ++i) ri[i] = '1';
add(l, mid, le);
add(mid + 1, r, ri);
}
void check(int l, int r, string s) {
if (l == r) {
int before = ans.size();
for (int i = 0; i < s.size(); ++i) {
if (s[i] == '0') ans.emplace_back(i);
}
assert(ans.size() == before + 1);
return;
}
int mid = l + r >> 1;
string le = s, ri = s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == '1') continue;
s[i] = '1'; bool flag = check_element(s);
if (flag) le[i] = '0', ri[i] = '1';
else le[i] = '1', ri[i] = '0';
}
check(l, mid, le);
check(mid + 1, r, ri);
}
vector<int> restore_permutation(int n, int w, int r) {
ans.clear(); ans.reserve(n);
add(0, n - 1, string(n, '0'));
compile_set();
check(0, n - 1, string(n, '0'));
return ans;
}
#ifdef hwe
signed main() {
cerr << '\n'; return 0;
}
#endif
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void add(int, int, std::string)':
messy.cpp:86:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
86 | int mid = l + r >> 1;
| ~~^~~
messy.cpp: In function 'void check(int, int, std::string)':
messy.cpp:105:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
105 | for (int i = 0; i < s.size(); ++i) {
| ~~^~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
from messy.cpp:5:
messy.cpp:108:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
108 | assert(ans.size() == before + 1);
| ~~~~~~~~~~~^~~~~~~~~~~~~
messy.cpp:112:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
112 | int mid = l + r >> 1;
| ~~^~~
messy.cpp:115:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
115 | for (int i = 0; i < s.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... |