Submission #662179

# Submission time Handle Problem Language Result Execution time Memory
662179 2022-11-26T07:21:29 Z alvingogo Monster Game (JOI21_monster) C++17
100 / 100
102 ms 416 KB
#include <bits/stdc++.h>
#include "monster.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

vector<int> dc(int l,int r){
    if(l==r){
        return vector<int>(1,l);
    }
    int m=(l+r)/2;
    auto a=dc(l,m);
    auto b=dc(m+1,r);
    int i=0,j=0;
    vector<int> c;
    int x=a.size(),y=b.size();
    while(i<=x-1 || j<=y-1){
        if(i>x-1){
            c.push_back(b[j]);
            j++;
        }
        else if(j>y-1){
            c.push_back(a[i]);
            i++;
        }
        else{
            if(!Query(a[i],b[j])){
                c.push_back(a[i]);
                i++;
            }
            else{
                c.push_back(b[j]);
                j++;
            }
        }
    }
    return c;
}
vector<int> se(vector<int> a,int big){
    int n=a.size();
    while(big<n-1){
        for(int i=big+1;i<n;i++){
            if(Query(a[big],a[i])){
                reverse(a.begin()+big+1,a.begin()+i+1);
                big=i;
                break;
            }
        }
    }
    return a;
}
int find0(vector<int>& a){
    int n=8;
    n=min(n,(int)a.size());
    vector<int> cnt(n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(Query(a[i],a[j])){
                cnt[i]++;
            }
            else{
                cnt[j]++;
            }
        }
    }
    vector<int> g;
    for(int i=0;i<n;i++){
        if(cnt[i]==1){
            g.push_back(i);
        }
    }
    if(Query(a[g[0]],a[g[1]])){
        return g[0];   
    }
    else{
        return g[1];
    }
}
vector<int> Solve(int N){
    auto h=dc(0,N-1);
    int x=find0(h);
    reverse(h.begin(),h.begin()+x+1);
    h=se(h,x);
    vector<int> k(N);
    for(int i=0;i<N;i++){
        k[h[i]]=i;
    }
    return k;
}
# 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 208 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 208 KB Output is correct
11 Correct 1 ms 208 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 280 KB Output is correct
16 Correct 14 ms 300 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 16 ms 208 KB Output is correct
20 Correct 9 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 7 ms 208 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 10 ms 208 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 208 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 208 KB Output is correct
11 Correct 1 ms 208 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 280 KB Output is correct
16 Correct 14 ms 300 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 16 ms 208 KB Output is correct
20 Correct 9 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 7 ms 208 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 10 ms 208 KB Output is correct
33 Correct 86 ms 208 KB Output is correct
34 Correct 95 ms 292 KB Output is correct
35 Correct 92 ms 208 KB Output is correct
36 Correct 80 ms 304 KB Output is correct
37 Correct 88 ms 292 KB Output is correct
38 Correct 70 ms 284 KB Output is correct
39 Correct 59 ms 416 KB Output is correct
40 Correct 77 ms 288 KB Output is correct
41 Correct 85 ms 292 KB Output is correct
42 Correct 79 ms 208 KB Output is correct
43 Correct 25 ms 292 KB Output is correct
44 Correct 46 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 284 KB Output is correct
2 Correct 84 ms 304 KB Output is correct
3 Correct 46 ms 296 KB Output is correct
4 Correct 94 ms 288 KB Output is correct
5 Correct 91 ms 300 KB Output is correct
6 Correct 41 ms 284 KB Output is correct
7 Correct 65 ms 296 KB Output is correct
8 Correct 78 ms 292 KB Output is correct
9 Correct 102 ms 284 KB Output is correct
10 Correct 38 ms 288 KB Output is correct
11 Correct 81 ms 208 KB Output is correct
12 Correct 38 ms 292 KB Output is correct
13 Correct 80 ms 304 KB Output is correct
14 Correct 62 ms 296 KB Output is correct
15 Correct 37 ms 288 KB Output is correct
16 Correct 37 ms 288 KB Output is correct
17 Correct 94 ms 284 KB Output is correct
18 Correct 39 ms 288 KB Output is correct