Submission #601642

# Submission time Handle Problem Language Result Execution time Memory
601642 2022-07-22T08:53:40 Z MohammadAghil Monster Game (JOI21_monster) C++17
10 / 100
719 ms 10896 KB
      #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 time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 652 ms 8424 KB Output is correct
17 Correct 569 ms 8460 KB Output is correct
18 Correct 473 ms 8608 KB Output is correct
19 Correct 640 ms 8532 KB Output is correct
20 Correct 551 ms 8628 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 604 ms 8576 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 516 ms 8648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 652 ms 8424 KB Output is correct
17 Correct 569 ms 8460 KB Output is correct
18 Correct 473 ms 8608 KB Output is correct
19 Correct 640 ms 8532 KB Output is correct
20 Correct 551 ms 8628 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 604 ms 8576 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 516 ms 8648 KB Output is correct
33 Incorrect 719 ms 10712 KB Wrong Answer [6]
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 609 ms 10896 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -