Submission #985918

#TimeUsernameProblemLanguageResultExecution timeMemory
985918SmuggingSpunExamination (JOI19_examination)C++14
100 / 100
577 ms32160 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; const int lim = 4e5 + 5; struct FenwickTree{ int bit[lim]; FenwickTree(){ memset(bit, 0, sizeof(bit)); } void update(int p){ for(; p < lim; p += p & -p){ bit[p]++; } } int get(int p){ int ans = 0; for(; p > 0; p -= p & -p){ ans += bit[p]; } return ans; } }; vector<tuple<int, int, int, int>>query; FenwickTree X, Y; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n, q; cin >> n >> q; map<int, int>index; for(int _ = 0; _ < n; _++){ int s, t; cin >> s >> t; query.emplace_back(s, t, s + t, index[s] = index[t] = 0); } for(int i = 1; i <= n; i++){ int x, y, z; cin >> x >> y >> z; index[x] = index[y] = 0; query.emplace_back(x, y, max(x + y, z), i); } sort(query.begin(), query.end(), [&] (auto i, auto j) -> bool{ if(get<2>(i) != get<2>(j)){ return get<2>(i) > get<2>(j); } return get<3>(i) < get<3>(j); }); int cnt = 0; for(auto& [x, y] : index){ y = ++cnt; } cnt = 0; vector<int>ans(q + 1); for(auto& [x, y, z, i] : query){ if(i == 0){ X.update(index[x]); Y.update(index[y]); cnt++; } else{ ans[i] = cnt - X.get(index[x] - 1) - Y.get(index[y] - 1); } } for(int i = 1; i <= q; i++){ cout << ans[i] << "\n"; } }

Compilation message (stderr)

examination.cpp: In function 'int main()':
examination.cpp:51:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   51 |  for(auto& [x, y] : index){
      |            ^
examination.cpp:56:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   56 |  for(auto& [x, y, z, i] : query){
      |            ^
examination.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   freopen(taskname".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...