제출 #601642

#제출 시각아이디문제언어결과실행 시간메모리
601642MohammadAghilMonster Game (JOI21_monster)C++17
10 / 100
719 ms10896 KiB
#include <bits/stdc++.h> #include <monster.h> // #pragma GCC optimize ("Ofast,unroll-loops") // #pragma GCC target ("avx2") using namespace std; typedef long long ll; typedef pair<int, int> pp; #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl #define per(i,r,l) for(int i = (r); i >= (l); i--) #define rep(i,l,r) for(int i = (l); i < (r); i++) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define pb push_back #define ss second #define ff first void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);} void IOS(){ cin.tie(0) -> sync_with_stdio(0); // #ifndef ONLINE_JUDGE // freopen("in.in", "r", stdin); // freopen("out.out", "w", stdout); // #endif } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll mod = 1e9 + 7, maxn = 5e5 + 5, lg = 22, inf = ll(1e9) + 5; ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;} // const int n = 5; // int a[5] = {3, 4, 0, 2, 1}; // bool Query(int a, int b){ // if(abs(::a[a] - ::a[b]) == 1) return ::a[a] < ::a[b]; // return ::a[a] > ::a[b]; // } vector<int> Solve(int n){ vector<int> ans(n); vector<int> cnt(n); rep(i,0,n) rep(j,0,i){ bool k = Query(i, j); er(i, j, k); cnt[i] += k, cnt[j] += k^1; } vector<int> mns, mxs; rep(i,0,n) if(cnt[i] == 1) mns.pb(i); rep(i,0,n) if(cnt[i] == n-2) mxs.pb(i); if(n == 4){ int mn = -1; for(int c: mns) { bool ok = true; for(int v: mxs){ if(Query(c, v)) ok = false; } if(ok) mn = c; } int mx = -1; for(int c: mxs) { bool ok = true; for(int v: mns){ if(!Query(c, v)) ok = false; } if(ok) mx = c; } if(mns[0] - mn) swap(mns[0], mns[1]); if(mxs[1] - mx) swap(mxs[1], mxs[0]); ans[mns[0]] = 0, ans[mns[1]] = 1; ans[mxs[0]] = 2, ans[mxs[1]] = 3; return ans; } rep(i,0,n){ if(cnt[i] > 1 && cnt[i] < n-2){ ans[i] = cnt[i]; } if(cnt[i] == 2){ int r = mns.back(); if(Query(i, r)) swap(mns[0], mns[1]); } if(cnt[i] == n-3){ int r = mxs.back(); if(Query(i, r)) swap(mxs[0], mxs[1]); } } ans[mns[0]] = 0, ans[mns[1]] = 1; ans[mxs[0]] = n-2, ans[mxs[1]] = n-1; return ans; } // int main(){ IOS(); // for(int c: Solve(n)) cout << c << ' '; // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...