제출 #1274013

#제출 시각아이디문제언어결과실행 시간메모리
1274013minhvule새 집 (APIO18_new_home)C++20
0 / 100
1173 ms94016 KiB
#include <bits/stdc++.h> using namespace std; #define task "task" #define fi first #define se second #define pb push_back #define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i ++) #define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; i --) #define bit(x, i) ((x >> i) & 1) #define oo 1e18 #define all(v) v.begin(), v.end() using ll = long long; using pii = pair<int, int>; using vi = vector<int>; // mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); // ll rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll>(l, r)(rd); } const int N = 3e5 + 5; const int mod = 1e9 + 7; const int base = 31; int n, k, q, x[N], t[N], a[N], b[N], cnt[N], sus = 0; vector<int> pos; map<int, int> dem; map<int, vector<int>> le, ri; set<int> s; void add(int i){ dem[x[i]] ++; s.insert(x[i]); if(cnt[t[i]] ++ == 0) sus ++; } void rem(int i){ if(-- dem[x[i]] == 0) s.erase(x[i]); if(-- cnt[t[i]] == 0) sus --; } void solve(){ cin>>n>>k>>q; FOR(i, 1, n){ cin>>x[i]>>t[i]>>a[i]>>b[i]; le[a[i]].pb(i); ri[b[i]].pb(i); pos.pb(a[i]); pos.pb(b[i]); } sort(pos.begin(), pos.end()); pos.resize(unique(pos.begin(), pos.end()) - pos.begin()); int i = 0; while(q --){ int l, y; cin>>l>>y; vector<int> sex; while(i < pos.size()){ if(pos[i] > y) break; for(int c : le[pos[i]]) add(c); for(int c : ri[pos[i]]) if(c == y) sex.pb(c); else rem(c); i ++; } if(sus != k){ cout<<-1<<'\n'; continue; } int mi = *s.begin(), ma = *s.rbegin(); cout<<max(abs(l - mi), abs(l - ma))<<'\n'; for(int c : sex) rem(c); } } int32_t main(){ ios::sync_with_stdio(false); cin.tie(NULL); if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int nTest = 1; // cin>>nTest; while(nTest --) solve(); // cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n"; return 0; } /* */

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

new_home.cpp: In function 'int32_t main()':
new_home.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...