QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465510 | #6303. Inversion | BalintR | WA | 1ms | 3792kb | C++20 | 2.1kb | 2024-07-06 23:39:02 | 2024-07-06 23:39:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef complex<double> cpx;
template <typename T> using minPq = priority_queue<T, vector<T>, greater<T>>;
#define ms(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define fs first
#define sn second
#define ALL(v) begin(v), end(v)
#define SZ(v) ((int) (v).size())
#define lbv(v, x) (lower_bound(ALL(v), x) - (v).begin())
#define ubv(v, x) (upper_bound(ALL(v), x) - (v).begin())
template <typename T> inline void UNIQUE(vector<T> &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
#define FR(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define dbg(x) {cerr << #x << ' ' << x << endl;}
#define dbgArr(arr, n) {cerr << #arr; FR(_i, n) cerr << ' ' << (arr)[_i]; cerr << endl;}
template <typename T, typename U>
ostream& operator<<(ostream &os, pair<T, U> p){return os << "(" << p.fs << ", " << p.sn << ")";}
const int MN = 2005;
int n;
int query(int l, int r){
if(r-l <= 1) return 0;
cout << l+1 << ' ' << r << endl;
int res; cin >> res;
return res;
}
vi ord;
int suf[MN], tmp[MN];
bool cmp(int l, int r){
int v1 = (query(l+1, r+1) ^ suf[l+1]) & 1;
int v2 = (query(l, r+1) ^ suf[l]) & 1;
return v1 ^ v2;
}
int main(){
cin.sync_with_stdio(0); cin.tie(0);
cin >> n;
FR(p, n){
int lo = 0, hi = SZ(ord);
while(lo < hi){
int mid = (lo+hi)/2;
if(cmp(ord[mid], p)) hi = mid;
else lo = mid+1;
}
ord.insert(ord.begin()+lo, p);
FOR(i, lo+1, SZ(ord)) tmp[ord[i]]++;
FORR(i, p-1, 0) suf[i] += tmp[i] += tmp[i+1];
ms(tmp, 0);
}
vi mp(n);
FR(i, n) mp[ord[i]] = i;
cout << "!";
FR(i, n) cout << ' ' << mp[i]+1;
cout << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3792kb
input:
3
output:
1 2
result:
wrong output format Unexpected end of file - int32 expected