# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112137 | 2019-05-17T15:01:49 Z | znfmxmrhlepf | New Home (APIO18_new_home) | C++14 | 5000 ms | 11324 KB |
#include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <iostream> using namespace std; typedef pair<int, int> pii; struct pos{int x, t, a, b;}; const int MAX_n = 3*100000; int n, q, k; pos str[MAX_n+1]; int main(){ scanf("%d %d %d", &n, &k, &q); vector<pii> locs; for(int i=0; i<n; i++){ scanf("%d %d %d %d", &str[i].x, &str[i].t, &str[i].a, &str[i].b); locs.push_back({str[i].x, i}); } sort(locs.begin(), locs.end()); for(int i=0; i<q; i++){ int ql, qy; scanf("%d %d", &ql, &qy); bool typeFlag[MAX_n]={0,}; vector<int> locs_x; for(int j=0; j<n; j++){ int idx = locs[j].second; if((str[idx].a-qy)*(str[idx].b-qy) <= 0){ // store j exist typeFlag[str[idx].t]=true; locs_x.push_back(locs[j].first); } } bool flag=true; for(int j=1; j<=k; j++){ if(!typeFlag[j]) flag=false; } if(!flag){ cout << -1; continue; } int lb; lb = lower_bound(locs_x.begin(), locs_x.end(), ql)-locs_x.begin(); if(lb == 0) printf("%d\n", locs_x[0]-ql); else if(lb == locs_x.size()) printf("%d\b", ql - locs_x.back()); else printf("%d\n", max(locs_x[lb]-ql, ql-locs_x[lb-1])); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 640 KB | Output is correct |
2 | Correct | 2 ms | 640 KB | Output is correct |
3 | Incorrect | 2 ms | 640 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 640 KB | Output is correct |
2 | Correct | 2 ms | 640 KB | Output is correct |
3 | Incorrect | 2 ms | 640 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5024 ms | 11324 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5059 ms | 9436 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 640 KB | Output is correct |
2 | Correct | 2 ms | 640 KB | Output is correct |
3 | Incorrect | 2 ms | 640 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 640 KB | Output is correct |
2 | Correct | 2 ms | 640 KB | Output is correct |
3 | Incorrect | 2 ms | 640 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |