답안 #376855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
376855 2021-03-12T05:37:13 Z wiwiho Minerals (JOI19_minerals) C++14
40 / 100
120 ms 4328 KB
#include "minerals.h"
 
#include<bits/stdc++.h>
 
#define mp make_pair
#define F first
#define S second
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}
#define eb emplace_back
 
using namespace std;
 
typedef long long ll;
 
using pll = pair<ll, ll>;
using pii = pair<int, int>;
 
ostream& operator<<(ostream& o, pll p){
    return o << '(' << p.F << ',' << p.S << ')';
}
 
vector<int> t;
vector<int> ans;
vector<pii> rng;

set<int> ma;
int query(int i){
    if(ma.find(i) == ma.end()) ma.insert(i);
    else ma.erase(i);
    return Query(i);
}
 
void dothing(int l, int r){
    for(int i = l; i <= r; i++) query(t[i]);
}
 
void check(int cnt, vector<int>& now, vector<int>& yes, vector<int>& no, int l, int r){
    for(int i : now){
        if(rng[i].S < l || r < rng[i].F){
            no.eb(i);
            continue;
        }
        int rs = query(i);
        //cerr << "check " << l << " " << r << " " << i << " " << rng[i] << " " << rs << "\n";
        if(rs == cnt) yes.eb(i);
        else no.eb(i);
        query(i);
    }
}
 
void bs(int l, int r, vector<int>& now){
    if(l > r || now.empty()) return;
    //cerr << "bs " << l << " " << r << "  ";
    //printv(now, cerr);
    if(l == r){
        for(int i : now) ans[i] = t[l];
        return;
    }
    int m = (l + r) / 2;
    dothing(l, m);
    //cerr << "ma ";
    //printv(ma, cerr);
    vector<int> yes, no;
    check(m - l + 1, now, yes, no, l, m);
    dothing(l, m);
    vector<int>().swap(now);
    bs(l, m, yes);
    bs(m + 1, r, no);
}
 
void Solve(int n){
 
    vector<int> now;
    ans.resize(2 * n + 1, -1);
    rng.resize(2 * n + 1);
    for(int i = 1; i <= 2 * n; i++){
        int r = query(i);
        if(r != t.size() + 1){
            now.eb(i);
            query(i);
            rng[i] = mp(0, (int)t.size() - 1);
        }
        else t.eb(i);
    }
    //printv(now, cerr);
    //printv(t, cerr);
    //printv(rng, cerr);
    for(int i : t) query(i);
 
    vector<int> tnow = now;
    bs(0, n - 1, tnow);
    //printv(ans, cerr);
    for(int i : now){
        Answer(i, ans[i]);
    }
 
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:83:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         if(r != t.size() + 1){
      |            ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 6 ms 492 KB Output is correct
3 Correct 13 ms 748 KB Output is correct
4 Correct 30 ms 1260 KB Output is correct
5 Correct 61 ms 2028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 13 ms 748 KB Output is correct
8 Correct 30 ms 1260 KB Output is correct
9 Correct 61 ms 2028 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 39 ms 1388 KB Output is correct
12 Correct 61 ms 1932 KB Output is correct
13 Correct 66 ms 2028 KB Output is correct
14 Correct 58 ms 1928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 13 ms 748 KB Output is correct
8 Correct 30 ms 1260 KB Output is correct
9 Correct 61 ms 2028 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 39 ms 1388 KB Output is correct
12 Correct 61 ms 1932 KB Output is correct
13 Correct 66 ms 2028 KB Output is correct
14 Correct 58 ms 1928 KB Output is correct
15 Incorrect 120 ms 4328 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 13 ms 748 KB Output is correct
8 Correct 30 ms 1260 KB Output is correct
9 Correct 61 ms 2028 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 39 ms 1388 KB Output is correct
12 Correct 61 ms 1932 KB Output is correct
13 Correct 66 ms 2028 KB Output is correct
14 Correct 58 ms 1928 KB Output is correct
15 Incorrect 120 ms 4328 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 13 ms 748 KB Output is correct
8 Correct 30 ms 1260 KB Output is correct
9 Correct 61 ms 2028 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 39 ms 1388 KB Output is correct
12 Correct 61 ms 1932 KB Output is correct
13 Correct 66 ms 2028 KB Output is correct
14 Correct 58 ms 1928 KB Output is correct
15 Incorrect 120 ms 4328 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 13 ms 748 KB Output is correct
8 Correct 30 ms 1260 KB Output is correct
9 Correct 61 ms 2028 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 39 ms 1388 KB Output is correct
12 Correct 61 ms 1932 KB Output is correct
13 Correct 66 ms 2028 KB Output is correct
14 Correct 58 ms 1928 KB Output is correct
15 Incorrect 120 ms 4328 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 13 ms 748 KB Output is correct
8 Correct 30 ms 1260 KB Output is correct
9 Correct 61 ms 2028 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 39 ms 1388 KB Output is correct
12 Correct 61 ms 1932 KB Output is correct
13 Correct 66 ms 2028 KB Output is correct
14 Correct 58 ms 1928 KB Output is correct
15 Incorrect 120 ms 4328 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 6 ms 492 KB Output is correct
7 Correct 13 ms 748 KB Output is correct
8 Correct 30 ms 1260 KB Output is correct
9 Correct 61 ms 2028 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 39 ms 1388 KB Output is correct
12 Correct 61 ms 1932 KB Output is correct
13 Correct 66 ms 2028 KB Output is correct
14 Correct 58 ms 1928 KB Output is correct
15 Incorrect 120 ms 4328 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -