제출 #112137

#제출 시각아이디문제언어결과실행 시간메모리
112137znfmxmrhlepf새 집 (APIO18_new_home)C++14
0 / 100
5059 ms11324 KiB
#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])); } }

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

new_home.cpp: In function 'int main()':
new_home.cpp:56:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   else if(lb == locs_x.size())
           ~~~^~~~~~~~~~~~~~~~
new_home.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &k, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &str[i].x, &str[i].t, &str[i].a, &str[i].b);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &ql, &qy);
   ~~~~~^~~~~~~~~~~~~~~~~~~
#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...