제출 #1260688

#제출 시각아이디문제언어결과실행 시간메모리
1260688tminhExamination (JOI19_examination)C++20
0 / 100
752 ms50204 KiB
#include "bits/stdc++.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define task "" #define ll long long #define endl '\n' #define fi first #define se second #define vall(a) (a).begin(), (a).end() #define sze(a) (int)a.size() #define pii pair<int, int> #define pll pair<ll, ll> #define ep emplace_back #define pb push_back #define pf push_front const ll mod = 1e9 + 7; const int N = 1e5 + 5; const ll oo = 1e18; bool START; int n, q; vector<int> arr; pii a[N]; struct node { int c, a, b, id; node(int c_, int a_, int b_, int id_) : c(c_), a(a_), b(b_), id(id_) {} bool operator<(const node &other) const { if (c == other.c) return id < other.id; return c > other.c; } }; vector<node> sw; int m; struct BIT { ordered_set<int> bit[N]; void add(int idx, int val) { idx = lower_bound(vall(arr), idx) - arr.begin() + 1; for (; idx <= m; idx += idx & -idx) bit[idx].insert(val); } int get(int idx, int val) { int ans = 0; idx = upper_bound(vall(arr), idx) - arr.begin(); for (; idx > 0; idx -= idx & -idx) ans += (sze(bit[idx]) - bit[idx].order_of_key(val)); return ans; } int get(int l, int r, int val) { return get(r, val) - get(l - 1, val); } } bit; int ans[N]; inline void solve() { sort(vall(arr)); arr.erase(unique(vall(arr)), arr.end()); m = sze(arr); sort(vall(sw)); for (auto[c, a, b, id] : sw) { if (!id) { bit.add(a, b); continue; } ans[id] = bit.get(a, arr.back(), b); } for (int i = 1; i <= q; ++i) cout << ans[i] << endl; } inline void input() { cin >> n >> q; for (int i = 1; i <= n; ++i) { cin >> a[i].fi >> a[i].se; arr.pb(a[i].fi); sw.pb(node(a[i].fi + a[i].se, a[i].fi, a[i].se, 0)); } for (int i = 1; i <= q; ++i) { int a, b, c; cin >> a >> b >> c; sw.pb(node(c, a, b, i)); } return solve(); } bool END; int main() { if(fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); input(); cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl; cerr << "Memory: " << fabs ((&END - &START)) / 1048576.0 << "MB\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

examination.cpp: In function 'int main()':
examination.cpp:103:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  103 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:104:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  104 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...