이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N, W, R;
vector<int> ans, ans2;
void put(int s, int e)
{
if(s+1==e) return;
int i, j;
int mid=s+e>>1;
string S(N, '0');
for(i=0; i<N; i++) if(!(s<=i && i<e)) S[i]='1';
for(i=s; i<mid; i++)
{
S[i]='1';
add_element(S);
S[i]='0';
}
put(s, mid);
put(mid, e);
}
void get(int s, int e, vector<int> cand)
{
if(s+1==e)
{
ans[s]=cand[0];
return;
}
int i, j;
int mid=s+e>>1;
string S(N, '0');
for(i=0; i<N; i++) if(!binary_search(cand.begin(), cand.end(), i)) S[i]='1';
vector<int> L, R;
for(auto it : cand)
{
S[it]='1';
if(check_element(S)) L.push_back(it);
else R.push_back(it);
S[it]='0';
}
get(s, mid, L);
get(mid, e, R);
}
vector<int> restore_permutation(int _N, int _W, int _R)
{
int i, j;
N=_N; W=_W; R=_R;
ans.resize(N);
ans2.resize(N);
vector<int> V;
for(i=0; i<N; i++) V.push_back(i);
put(0, N);
compile_set();
get(0, N, V);
for(i=0; i<N; i++) ans2[ans[i]]=i;
return ans2;
}
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void put(int, int)':
messy.cpp:16:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid=s+e>>1;
~^~
messy.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
messy.cpp: In function 'void get(int, int, std::vector<int>)':
messy.cpp:40:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid=s+e>>1;
~^~
messy.cpp:39:12: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:60:12: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
# | 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... |