답안 #888077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
888077 2023-12-15T23:40:46 Z vjudge1 Examination (JOI19_examination) C++17
0 / 100
2 ms 2396 KB
#include<bits/stdc++.h>
using namespace std;
struct st {
    int x, y, z, i;
};
vector<st> v;
struct fenwick {
    int t[400010];
    void upd(int n, int x) {
        for(;n<=4e5;n+=n&-n)
            t[n]+=x;
    }
    int q(int n) {
        int x = 0;
        for(;n;n-=n&-n)
            x+=t[n];
        return x;
    }
    int Q(int x) {
        return q(4e5)-q(x-1);
    }
} A,B;
int ans[100100];
map<int,int> mp;
int main() {
    freopen("lazy.in", "r", stdin);
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        mp[a], mp[b];
        v.push_back({a,b,a+b,0});
    }
    for(int i = 1; i <= n; i++) {
        int x,y,z;
        cin >> x >> y>> z;
        mp[x],mp[y];
        v.push_back({x,y,z,i});
    }
    sort(v.begin(),v.end(),[](st a, st b) {
        return (a.z-b.z?a.z>b.z:a.i<b.i);
    });
    int cnt = 0;
    for(auto &i: mp)
        i.second=++cnt;
    cnt=0;
    for(auto i: v)
        if(i.i)
            ans[i.i]=A.Q(mp[i.x])+B.Q(mp[i.y])-cnt;
        else
            A.upd(mp[i.x],1),B.upd(mp[i.y],1),cnt++;
    for(int i = 1; i <= q; i++)
        cout << ans[i] << '\n';
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen("lazy.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -