답안 #804056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804056 2023-08-03T06:59:35 Z fatemetmhr Monster Game (JOI21_monster) C++17
10 / 100
166 ms 4472 KB
// Be name khoda //
 
#include "monster.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second
#define mp     make_pair
 
namespace {
 
const int maxn5 = 2e3 + 10;
 
int cnt[maxn5], st[maxn5][maxn5];
 
void msort(vector <int> &a){
    if(a.size() <= 1)
        return;
    if(a.size() == 3){
    }
    int pt = 0;
    vector <int> av1, av2;
    for(int i = 0; i < a.size(); i++) if(i != pt){
        if(Query(a[i], a[pt]))
            av2.pb(a[i]);
        else
            av1.pb(a[i]);
    }
    msort(av1);
    msort(av2);
    if(av1.size() && av2.size() && Query(av1.back(), av2[0]))
        swap(av1[int(av1.size()) - 1], av2[0]);
    int keep = a[pt];
    a.clear();
    for(auto u : av1)
        a.pb(u);
    a.pb(keep);
    for(auto u : av2)
        a.pb(u);
}
 
bool cmp(int i, int j){return cnt[i] < cnt[j] || (cnt[i] == cnt[j] && st[i][j]);}
 
 
}  // namespace
 
std::vector<int> Solve(int n) {
 
    vector <int> ret(n), a(n);
    for(int i = 0; i < n; i++)
        a[i] = i;
    for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++){
        st[i][j] = Query(i, j);
        st[j][i] = st[i][j] ^ 1;
    }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++) if(i != j)
            cnt[i] += st[i][j];
    sort(all(a), cmp);
    /*
    for(int i = 0; i < n; i++)
        cout << cnt[i] << ' ';
    cout << endl;
    for(int i = 0; i < n; i++)
        cout << a[i] << ' ';
    cout << endl;
    */
    /*
    for(int i = 0; i < n; i++)
        cout << a[i] << ' ';
    cout << endl;
    */
    for(int i = 0; i < n; i++){
        ret[a[i]] = i;
    }
    return ret;
}

Compilation message

monster.cpp: In function 'void {anonymous}::msort(std::vector<int>&)':
monster.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0; i < a.size(); i++) if(i != pt){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 256 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 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
15 Correct 0 ms 336 KB Output is correct
16 Correct 144 ms 1216 KB Output is correct
17 Correct 140 ms 1180 KB Output is correct
18 Correct 158 ms 1212 KB Output is correct
19 Correct 159 ms 1192 KB Output is correct
20 Correct 128 ms 1220 KB Output is correct
21 Correct 0 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 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 166 ms 1220 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 0 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 64 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 256 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 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
15 Correct 0 ms 336 KB Output is correct
16 Correct 144 ms 1216 KB Output is correct
17 Correct 140 ms 1180 KB Output is correct
18 Correct 158 ms 1212 KB Output is correct
19 Correct 159 ms 1192 KB Output is correct
20 Correct 128 ms 1220 KB Output is correct
21 Correct 0 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 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 166 ms 1220 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 0 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 64 ms 1228 KB Output is correct
33 Incorrect 161 ms 4424 KB Wrong Answer [6]
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 165 ms 4472 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -