이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
//#include "grader.cpp"
#include <set>
#include <vector>
#include <iostream>
using namespace std;
int getLog(int x)
{
int ans = 0;
while((1<<ans)!=x) ans++;
return ans;
}
void gen(string curr, int n, int ones, int zeros, vector <string> &v, vector <string> &all)
{
if(curr.size()==n)
{
bool fail = true;
for(int i = 0;i<n;i++)
{
if(curr[i]!=curr[0])
{
fail = false;
break;
}
}
all.push_back(curr);
if(fail==false && v.size()<(1<<n)/6)
{
v.push_back(curr);
add_element(curr);
}
//cout << curr << '\n';
return;
}
gen(curr+"0", n, ones, zeros+1, v, all);
gen(curr+"1", n, ones+1, zeros, v, all);
}
set <string> permSet[15][15];
vector<int> restore_permutation(int n, int w, int r)
{
int logN = getLog(n);
vector <string> v, all;
gen("", n, 0, 0, v, all);
compile_set();
//cout << "COMPILED" << '\n';
vector <int> p;
for(int i = 0;i<n;i++) p.push_back(i);
for(int i = 0;i<n;i++)
{
for(int j = i;j<n;j++)
{
swap(p[i], p[j]);
for(string s: v)
{
string newS;
for(int x: p) newS += s[x];
permSet[i][j].insert(newS);
}
//cout << i << " " << j << " -> " << permSet[i][j].size() << '\n';
swap(p[i], p[j]);
}
}
vector <bool> base;
for(string s: all) base.push_back(check_element(s));//, cout << base.back() << '\n';
for(int i = 0;i<n;i++)
{
for(int j = i;j<n;j++)
{
swap(p[i], p[j]);
bool fail = false;
for(int k = 0;k<all.size();k++)
{
if(base[k]!=permSet[i][j].count(all[k]))
{
fail = true;
break;
}
}
if(fail==false)
{
//cout << "A de " << i << " " << j << '\n';
return p;
}
swap(p[i], p[j]);
}
}
cout << "FAK" << '\n';
return {};
}
컴파일 시 표준 에러 (stderr) 메시지
messy.cpp: In function 'void gen(std::string, int, int, int, std::vector<std::__cxx11::basic_string<char> >&, std::vector<std::__cxx11::basic_string<char> >&)':
messy.cpp:20:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(curr.size()==n)
| ~~~~~~~~~~~^~~
messy.cpp:33:35: warning: comparison of integer expressions of different signedness: 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
33 | if(fail==false && v.size()<(1<<n)/6)
| ~~~~~~~~^~~~~~~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:93:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
93 | for(int k = 0;k<all.size();k++)
| ~^~~~~~~~~~~
messy.cpp:52:9: warning: unused variable 'logN' [-Wunused-variable]
52 | int logN = getLog(n);
| ^~~~
# | 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... |