답안 #1113168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113168 2024-11-16T01:57:07 Z lucascgar 운세 보기 2 (JOI14_fortune_telling2) C++17
4 / 100
204 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

/*
foco no cara da esquerda ativado ou nn

query so na esquerda: desligo
na direita: mudo
*/

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;

const int MAXN = 5e4+10, MAXTT = 2*MAXN;

int s[MAXN], l[MAXN];

bitset<MAXN> r, es[MAXTT], di[MAXTT];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    int a, b;

    vector<pii> ord;

    for (int i=1;i<=n;i++){
        cin >> a >> b;
        s[i] = min(a,b), l[i] = max(a,b);
        if (a<b) r[i]=1;
        ord.emplace_back(l[i], i);
        ord.emplace_back(s[i], i);

    }

    sort(ord.begin(), ord.end());

    vector<int> count(ord.size());
    int cnt = 1;
    es[1].flip();
    for (int i=0;i<ord.size();i++){
        if (i>0 && ord[i].first != ord[i-1].first){
            cnt++;
            es[cnt] = es[cnt-1], di[cnt]=di[cnt-1];
        }
        count[i] = cnt;
        auto [v, x] = ord[i];

        if (v == s[x]){
            es[cnt][x] =0;
        }else{
            es[cnt][x] = 1;
            di[cnt][x]=1;
        }

    }

    int t;
    for (int i=1;i<=k;i++){
        cin >> t;
        pii srch = {t+1, -1};
        int pos = upper_bound(ord.begin(), ord.end(), srch) - ord.begin() - 1;
        if (pos<0) continue;
        int v = count[pos];
        r = r^di[v];
        r = r&es[v];
        // cerr << es[v][1] << ' ' << di[v][1] << '\n';

    }

    long long ss = 0;
    for (int i=1;i<=n;i++){
        if (r[i] == 1) ss += s[i];
        else ss+=l[i];
    }    

    cout << ss << '\n';

    return 0;
}

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i=0;i<ord.size();i++){
      |                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2896 KB Output is correct
2 Correct 12 ms 12640 KB Output is correct
3 Correct 21 ms 24904 KB Output is correct
4 Correct 23 ms 24996 KB Output is correct
5 Correct 20 ms 24904 KB Output is correct
6 Correct 21 ms 24912 KB Output is correct
7 Correct 20 ms 25424 KB Output is correct
8 Correct 19 ms 25424 KB Output is correct
9 Correct 23 ms 25476 KB Output is correct
10 Correct 13 ms 14928 KB Output is correct
11 Correct 11 ms 13392 KB Output is correct
12 Correct 12 ms 13392 KB Output is correct
13 Correct 13 ms 14528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2896 KB Output is correct
2 Correct 12 ms 12640 KB Output is correct
3 Correct 21 ms 24904 KB Output is correct
4 Correct 23 ms 24996 KB Output is correct
5 Correct 20 ms 24904 KB Output is correct
6 Correct 21 ms 24912 KB Output is correct
7 Correct 20 ms 25424 KB Output is correct
8 Correct 19 ms 25424 KB Output is correct
9 Correct 23 ms 25476 KB Output is correct
10 Correct 13 ms 14928 KB Output is correct
11 Correct 11 ms 13392 KB Output is correct
12 Correct 12 ms 13392 KB Output is correct
13 Correct 13 ms 14528 KB Output is correct
14 Correct 204 ms 246432 KB Output is correct
15 Runtime error 193 ms 262144 KB Execution killed with signal 9
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2896 KB Output is correct
2 Correct 12 ms 12640 KB Output is correct
3 Correct 21 ms 24904 KB Output is correct
4 Correct 23 ms 24996 KB Output is correct
5 Correct 20 ms 24904 KB Output is correct
6 Correct 21 ms 24912 KB Output is correct
7 Correct 20 ms 25424 KB Output is correct
8 Correct 19 ms 25424 KB Output is correct
9 Correct 23 ms 25476 KB Output is correct
10 Correct 13 ms 14928 KB Output is correct
11 Correct 11 ms 13392 KB Output is correct
12 Correct 12 ms 13392 KB Output is correct
13 Correct 13 ms 14528 KB Output is correct
14 Correct 204 ms 246432 KB Output is correct
15 Runtime error 193 ms 262144 KB Execution killed with signal 9
16 Halted 0 ms 0 KB -