답안 #1048467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048467 2024-08-08T07:49:12 Z otarius Examination (JOI19_examination) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
 
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
 
// #define int long long
// #define int unsigned long long
 
#define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>
 
void open_file(string filename) {
    freopen((filename + ".in").c_str(), "r", stdin);
    freopen((filename + ".out").c_str(), "w", stdout);
}
 
// const ll mod = 1e9 + 7;
// const ll mod = 998244353;
 
const ll inf = 1e9;
const ll biginf = 1e18;
const int maxN = 2 * 1e5 + 25;

struct node {
    int a, b, c, id;
};
bool comp(node x, node y) {
    return x.a < y.a;
}
node arr[maxN];
void update(int x, int val) {
    for ( ; x; x -= (x & -x)) bit[x].insert({val, ++tim});
}
int query(int x, int val) {
    int ans = 0;
    for ( ; x < maxN; x += (x & -x))
        ans += bit[x].size() - bit[x].order_of_key({val - 1, 2 * inf + 1e5});
    return ans;
}
void solve() {
    int n, q;
    cin >> n >> q;
    int ans[q + 1];
    for (int i = 1; i <= n; i++) {
        cin >> arr[i].a >> arr[i].b;
        arr[i].c = arr[i].a + arr[i].b; arr[i].id = 0;
    } for (int i = 1; i <= q; i++) {
        cin >> arr[i].a >> arr[i].b >> arr[i].c; arr[i].id = i;
    } sort(arr + 1, arr + n + q + 1, comp);
    vector<int> x;
    for (int i = 1; i <= n + q; i++) x.pb(arr[i].b);
    sort(all(x)); x.resize(unique(all(x)) - x.begin());
    for (int i = 1; i <= n + q; i++)
        arr[i].b = lower_bound(all(x), arr[i].b) - x.begin() + 1;
    for (int i = n + q; i >= 1; i--) {
        ans[arr[i].id] = query(arr[i].b, arr[i].c);
        if (arr[i].id == 0) update(arr[i].b, arr[i].c);
    } for (int i = 1; i <= q; i++) cout << ans[i] << '\n';
}
int32_t main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
        cout << '\n';
    }
    return 0;
}

Compilation message

examination.cpp: In function 'void update(int, int)':
examination.cpp:45:31: error: 'bit' was not declared in this scope
   45 |     for ( ; x; x -= (x & -x)) bit[x].insert({val, ++tim});
      |                               ^~~
examination.cpp:45:53: error: 'tim' was not declared in this scope; did you mean 'time'?
   45 |     for ( ; x; x -= (x & -x)) bit[x].insert({val, ++tim});
      |                                                     ^~~
      |                                                     time
examination.cpp: In function 'int query(int, int)':
examination.cpp:50:16: error: 'bit' was not declared in this scope
   50 |         ans += bit[x].size() - bit[x].order_of_key({val - 1, 2 * inf + 1e5});
      |                ^~~
examination.cpp: In function 'void open_file(std::string)':
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((filename + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((filename + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~