제출 #213130

#제출 시각아이디문제언어결과실행 시간메모리
213130ainta함박 스테이크 (JOI20_hamburg)C++17
15 / 100
217 ms4296 KiB
#include<cstdio> #include<algorithm> #define N_ 201000 using namespace std; int K, C[N_]; struct Rect { int bx, by, ex, ey; bool operator<(const Rect &p)const { return bx < p.bx; } }w[N_]; struct point { int x, y; }U[5]; bool Inside(Rect a, point b) { return a.bx <= b.x&&b.x <= a.ex&&a.by <= b.y&&b.y <= a.ey; } void Print(point a) { printf("%d %d\n", a.x, a.y); } void Do(int pv, int n) { int i; if (pv) { for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]++; } if (pv == K) { for (i = 1; i <= n; i++) if (!C[i])break; if (i > n) { for (i = 0; i < K; i++)Print(U[i]); exit(0); } for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]--; return; } int Ax = 0, Bx = 1e9, Ay = 0, By = 1e9; for (i = 1; i <= n; i++) { if (C[i])continue; Ax = max(Ax, w[i].bx); Ay = max(Ay, w[i].by); Bx = min(Bx, w[i].ex); By = min(By, w[i].ey); } if (pv == K - 1) { if (Ax <= Bx && Ay <= By) { U[pv] = { Ax,Ay }; Do(pv + 1, n); } else { if (pv) for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]--; return; } } int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 1e9; int xx1 = 0, xx2 = 1e9, xx3 = 0, xx4 = 1e9; for (i = 1; i <= n; i++) { if (C[i])continue; if (w[i].bx <= Bx) { yy1 = max(yy1, w[i].by); yy2 = min(yy2, w[i].ey); } if (w[i].ex >= Ax) { yy3 = max(yy3, w[i].by); yy4 = min(yy4, w[i].ey); } if (w[i].by <= By) { xx1 = max(xx1, w[i].bx); xx2 = min(xx2, w[i].ex); } if (w[i].ey >= Ay) { xx3 = max(xx3, w[i].bx); xx4 = min(xx4, w[i].ex); } } U[pv] = { Bx, yy1 }; Do(pv + 1, n); U[pv] = { Bx, yy2 }; Do(pv + 1, n); U[pv] = { Ax, yy3 }; Do(pv + 1, n); U[pv] = { Ax, yy4 }; Do(pv + 1, n); if (pv) { for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]--; } } int main() { int i, n; scanf("%d%d", &n, &K); for (i = 1; i <= n; i++) { scanf("%d%d%d%d", &w[i].bx, &w[i].by, &w[i].ex, &w[i].ey); } Do(0, n); sort(w + 1, w + n + 1); int Ax = 0, Bx = 1e9, Ay = 0, By = 1e9; for (i = n; i >= 1; i--) { Ax = max(Ax, w[i].bx); Ay = max(Ay, w[i].by); Bx = min(Bx, w[i].ex); By = min(By, w[i].ey); if (Ax > Bx || Ay > By)break; } int pv = i; Ax = 0, Bx = 1e9, Ay = 0, By = 1e9; for (i = n; i > pv; i--) { Ax = max(Ax, w[i].bx); Ay = max(Ay, w[i].by); Bx = min(Bx, w[i].ex); By = min(By, w[i].ey); } U[0] = { Ax,Ay }; for (i = 1; i <= n; i++)if (Inside(w[i], U[0]))C[i]++; Do(1, n); }

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

hamburg.cpp: In function 'int main()':
hamburg.cpp:88:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   88 |  scanf("%d%d", &n, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~
hamburg.cpp:90:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   90 |   scanf("%d%d%d%d", &w[i].bx, &w[i].by, &w[i].ex, &w[i].ey);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...