이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
int N;
/*
void add_element(string s)
{
cout<< "Added " << s << "\n";
}
void compile_set()
{
cout<< "COMPILING SETS" << "\n";
}
bool check_element(string s)
{
cout<< "Checking " << s << "\n";
int ans; cin>> ans;
return ans;
}
*/
void AddRecursive(int p1, int p2)
{
string bit(N, '1');
if (p2 - p1 == 1)
{
bit.replace(0, bit.length(), bit.length(), '1');
bit[p1] = '0';
add_element(bit);
return;
}
bit.replace(p1, (p2 - p1 + 1), (p2 - p1 + 1), '0');
int m = (p1 + p2) >> 1;
for (int i = p1; i <= m; i++)
{
bit[i] = '1';
add_element(bit);
bit[i] = '0';
}
AddRecursive(p1, m);
AddRecursive(m + 1, p2);
}
void CheckRecursive(int p1, int p2, vector<int> &CheckBit, vector<int> &result)
{
string bit(N, '1');
for (int i = 0; i < CheckBit.size(); i++)
bit[CheckBit[i]] = '0';
if (p2 - p1 == 1)
{
bit[CheckBit[0]] = '1';
if (check_element(bit))
{
result[CheckBit[1]] = p1;
result[CheckBit[0]] = p2;
}
else
{
result[CheckBit[1]] = p2;
result[CheckBit[0]] = p1;
}
return;
}
vector<int> BotHalf, TopHalf;
for (int i = 0; i < CheckBit.size(); i++)
{
bit[CheckBit[i]] = '1';
if (check_element(bit))
BotHalf.push_back(CheckBit[i]);
else
TopHalf.push_back(CheckBit[i]);
bit[CheckBit[i]] = '0';
}
int m = (p1 + p2) >> 1;
CheckRecursive(p1, m, BotHalf, result);
CheckRecursive(m + 1, p2, TopHalf, result);
}
vector<int> restore_permutation(int n, int w, int r)
{
N = n;
AddRecursive(0, n - 1);
compile_set();
vector<int> CheckBit(n);
vector<int> result(n);
for (int i = 0; i < n; i++)
CheckBit[i] = i;
CheckRecursive(0, n - 1, CheckBit, result);
return result;
}
/*
int main()
{
int n = 8, w = 0, r = 0;
vector<int> v(100);
vector<int> ans = restore_permutation(n, w, r);
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void CheckRecursive(int, int, std::vector<int>&, std::vector<int>&)':
messy.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for (int i = 0; i < CheckBit.size(); i++)
| ~~^~~~~~~~~~~~~~~~~
messy.cpp:74:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for (int i = 0; i < CheckBit.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... |