답안 #662212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
662212 2022-11-26T07:38:45 Z alvingogo Monster Game (JOI21_monster) C++17
100 / 100
91 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=12;
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 228 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 256 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 208 KB Output is correct
16 Correct 9 ms 300 KB Output is correct
17 Correct 12 ms 296 KB Output is correct
18 Correct 10 ms 208 KB Output is correct
19 Correct 10 ms 300 KB Output is correct
20 Correct 11 ms 208 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 2 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 11 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 0 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 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 228 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 256 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 208 KB Output is correct
16 Correct 9 ms 300 KB Output is correct
17 Correct 12 ms 296 KB Output is correct
18 Correct 10 ms 208 KB Output is correct
19 Correct 10 ms 300 KB Output is correct
20 Correct 11 ms 208 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 2 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 11 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 0 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 300 KB Output is correct
33 Correct 80 ms 304 KB Output is correct
34 Correct 90 ms 300 KB Output is correct
35 Correct 76 ms 296 KB Output is correct
36 Correct 61 ms 300 KB Output is correct
37 Correct 85 ms 416 KB Output is correct
38 Correct 82 ms 208 KB Output is correct
39 Correct 84 ms 288 KB Output is correct
40 Correct 57 ms 300 KB Output is correct
41 Correct 45 ms 300 KB Output is correct
42 Correct 85 ms 412 KB Output is correct
43 Correct 47 ms 296 KB Output is correct
44 Correct 56 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 292 KB Output is correct
2 Correct 82 ms 208 KB Output is correct
3 Correct 90 ms 296 KB Output is correct
4 Correct 89 ms 300 KB Output is correct
5 Correct 79 ms 296 KB Output is correct
6 Correct 60 ms 412 KB Output is correct
7 Correct 43 ms 336 KB Output is correct
8 Correct 83 ms 288 KB Output is correct
9 Correct 75 ms 300 KB Output is correct
10 Correct 88 ms 416 KB Output is correct
11 Correct 91 ms 284 KB Output is correct
12 Correct 61 ms 292 KB Output is correct
13 Correct 68 ms 208 KB Output is correct
14 Correct 70 ms 336 KB Output is correct
15 Correct 48 ms 208 KB Output is correct
16 Correct 58 ms 296 KB Output is correct
17 Correct 86 ms 208 KB Output is correct
18 Correct 40 ms 288 KB Output is correct