# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247364 | errorgorn | Mouse (info1cup19_mouse) | C++14 | 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 "grader.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
mt19937 rng (42069);
set<ii> tested;
void solve(int n){
vector<int> v;
rep(x,1,n+1){
v.push_back(x);
}
int curr=query(v);
while (curr!=n){
int i,j;
do{
i=rng()%n,j=rng()%n;
if (i>j) swap(i,j);
} while (i==j && !tested.count(ii(i,j));
swap(v[i],v[j]);
int temp=query(v);
if (temp<curr){
swap(v[i],v[j]);
tested.insert(ii(i,j));
}
else{
tested.clear();
curr=temp;
}
}
}