답안 #201373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201373 2020-02-10T10:31:40 Z Rakhmand Examination (JOI19_examination) C++14
20 / 100
106 ms 4600 KB
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)

const int MXN = 1e6 + 10;
const long long MNN = 1e6 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 2e9;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

void istxt(bool yes){
    if(yes == 1){
        freopen("balancing.in", "r", stdin);
        freopen("balancing.out", "w", stdout);
    }else{
        freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin);
    }
}

int n, q, ans[MXN], mp[MXN];

struct childish{
    int a, b;
}p[MXN];

struct test{
    int a, b, c, ind;
}e[MXN];

bool cmp1(test a, test b){
    if(a.a == b.a) return a.b < b.b;
    else return a.a < b.a;
}

bool cmp(childish a, childish b){
    if(a.a != b.a) return a.a < b.a;
    else return a.b < b.b;
}

void upd(int pos, int x){
    for(; pos <= 1e6; pos = (pos | (pos + 1))){
        mp[pos] += x;
    }
}

int get(int pos){
    int sum = 0;
    while(pos >= 0){
        sum += mp[pos];
        pos = (pos & (pos + 1)) - 1;
    }
    return sum;
}

int main () {
    ios;
    //istxt(0);
    cin >> n >> q;
    for(int i = 1; i <= n; i++){
        cin >> p[i].a >> p[i].b;
        upd(p[i].b, 1);
    }
    sort(p + 1, p + n + 1, cmp);
    for(int i = 1; i <= q; i++){
        cin >> e[i].a >> e[i].b >> e[i].c;
        e[i].ind = i;
    }
    sort(e + 1, e + q + 1, cmp1);
    int cnt = 1;
    for(int i = 1; i <= q; i++){
        while(cnt <= n && e[i].a > p[cnt].a){
            upd(p[cnt].b, -1);
            cnt++;
        }
        if(cnt <= n) ans[e[i].ind] = n - cnt + 1 - get(e[i].b - 1);
        else ans[e[i].ind] = 0;
    }
    for(int i = 1; i <= q; i++){
        cout << ans[i] << nl;
    }
    return 0;
}

Compilation message

examination.cpp: In function 'void istxt(bool)':
examination.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("balancing.in", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("balancing.out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 4088 KB Output is correct
2 Correct 102 ms 4472 KB Output is correct
3 Correct 99 ms 4472 KB Output is correct
4 Correct 88 ms 4088 KB Output is correct
5 Correct 92 ms 4600 KB Output is correct
6 Correct 75 ms 4088 KB Output is correct
7 Correct 97 ms 4472 KB Output is correct
8 Correct 104 ms 4472 KB Output is correct
9 Correct 88 ms 4472 KB Output is correct
10 Correct 86 ms 4344 KB Output is correct
11 Correct 89 ms 3960 KB Output is correct
12 Correct 61 ms 3708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 4088 KB Output is correct
2 Correct 102 ms 4472 KB Output is correct
3 Correct 99 ms 4472 KB Output is correct
4 Correct 88 ms 4088 KB Output is correct
5 Correct 92 ms 4600 KB Output is correct
6 Correct 75 ms 4088 KB Output is correct
7 Correct 97 ms 4472 KB Output is correct
8 Correct 104 ms 4472 KB Output is correct
9 Correct 88 ms 4472 KB Output is correct
10 Correct 86 ms 4344 KB Output is correct
11 Correct 89 ms 3960 KB Output is correct
12 Correct 61 ms 3708 KB Output is correct
13 Incorrect 106 ms 4600 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -