# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120879 | vjudge1 | Art Collections (BOI22_art) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "art.h"
int used[1111][1111];
using namespace std;
void solve(int n) {
vector <int> v, v2;
for(int i = 1; i <= n; i++) {
v.push_back(i);
}
int res = publish(v);
for(int i = 0; i < v.size(); i++) {
bool bb = 0;
ll p1 =i, p2 = i;
for(int j = 0; j < v.size(); j++) {
if(i == j) continue;
if(used[i][v[j]] == 1 && used[j][v[i]] == 1) continue;
swap(v[i], v[j]);
used[i][v[j]] = 1;
used[j][v[i]] = 1;
int cur = publish(v);
if(cur == 0) {
answer(v);
return;
}
if(cur > res) {
swap(v[i], v[j]);
swap(v[p1], v[p2]);
if(bb == 1) break;
}
else {
p1 = i;
p2 = j;
bb = 1;
res = cur;
swap(v[i], v[j]);
}
}
}
answer(v);
}//