이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <ctype.h>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#ifndef death
#include "messy.h"
#endif
using namespace std;
#ifdef death
map<string, bool> USED;
vector<int> P;
void add_element(string s)
{
string t = s;
for (int i = 0; i < P.size(); i++)
t[i] = s[P[i]];
USED[t] = 1;
}
void compile_set()
{
}
bool check_element(string s)
{
return USED[s];
}
#endif
int n;
string s;
vector<pair<string, pair<int, int>>> v;
vector<int> p;
void build(int l,int r)
{
if (l == r)
return;
int m = (l + r) / 2;
for (int i = l; i < m; i++)
s[i] = '1';
add_element(s);
for (int i = l; i < m; i++)
for (int j = m; j <= r; j++)
{
swap(s[i],s[j]);
v.PB(MP(s, MP(i, j)));
swap(s[i],s[j]);
}
for (int i = l; i < m; i++)
s[i] = '0';
}
int Main()
{
for (int i = 0; i < n; i++)
{
s += "0";
p.PB(i);
}
build(0, n-1);
compile_set();
for(int i=0;i<v.size();i++)
if (check_element(v[i].first))
{
swap(p[v[i].second.first], p[v[i].second.second]);
break;
}
return 0;
}
vector<int> restore_permutation(int N, int w, int r)
{
n = N;
Main();
return p;
}
#ifdef death
int main()
{
int N, R, W;
cin >> N >> W >> R;
for (int i = 0; i < N; i++)
{
P.PB(0);
cin >> P.back();
}
P = restore_permutation(N,W,R);
for (int i = 0; i < N; i++)
cout << P[i] << " ";
cout << endl;
return 0;
}
#endif
/*
8 0 0
0 3 2 1 4 5 6 7
*/
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'int Main()':
messy.cpp:91:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v.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... |