Submission #413642

#TimeUsernameProblemLanguageResultExecution timeMemory
413642hhhhauraNew Home (APIO18_new_home)C++14
5 / 100
5054 ms17048 KiB
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i++) #define rrep(i ,a, b) for(int i = b; i >= a; i--) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) #define INF 1e9 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().times_since_epoch().count()) #ifdef wiwihorz #define print(a...) kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} #else #define print(...) 0 #define vprint(...) 0 #endif namespace solver { int n, k; vector<int> x, t, a, b, mn; void init_(int _n, int _k) { n = _n, k = _k; x.assign(n + 1, 0); t.assign(n + 1, 0); a.assign(n + 1, 0); b.assign(n + 1, 0); mn.assign(k + 1, 0); } int query(int l, int y) { mn.assign(k + 1, INF); rep(i, 1, n) if(a[i] <= y && b[i] >= y) { mn[t[i]] = min(mn[t[i]], abs(l - x[i])); } int ans = 0; rep(i, 1, k) ans = max(ans, mn[i]); if(ans == INF) return -1; return ans; } }; namespace io { const int SIZE = 1e7 + 10; char inbuff[SIZE]; char *l, *r; inline void init() { l = inbuff; r = inbuff + fread(inbuff, 1, SIZE, stdin); } inline char gc() { if (l == r) init(); return (l != r) ? *(l++) : EOF; } void read(int &x) { x = 0; char ch = gc(); while(!isdigit(ch)) ch = gc(); while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc(); } } using io::read; using namespace solver; signed main() { int n, k, q; read(n), read(k), read(q); init_(n, k); rep(i, 1, n) { read(x[i]), read(t[i]); read(a[i]), read(b[i]); } rep(i, 1, q) { int l, y; read(l), read(y); printf("%d\n", query(l, y)); } return 0; }

Compilation message (stderr)

new_home.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
new_home.cpp:22:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   22 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
new_home.cpp:22:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   22 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
#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...