Submission #309621

#TimeUsernameProblemLanguageResultExecution timeMemory
309621aintaHamburg Steak (JOI20_hamburg)C++17
15 / 100
3066 ms4344 KiB
#include<cstdio> #include<algorithm> #define N_ 201000 using namespace std; int n, K, C[N_]; struct Rect { int bx, by, ex, ey; }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 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); } int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 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); } } U[pv] = { Bx, yy1 }; Do(pv + 1); U[pv] = { Bx, yy2 }; Do(pv + 1); U[pv] = { Ax, yy3 }; Do(pv + 1); U[pv] = { Ax, yy4 }; Do(pv + 1); if (pv) { for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]--; } } int main() { int i; 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); } if(K<=3){ Do(0); } int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 1e9; int Ax = 0, Bx = 1e9, Ay = 0, By = 1e9; for (i = 1; i <= n; 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); } for(i=1;i<=n;i++){ U[0]={Bx,w[i].ey}; Do(1); } }

Compilation message (stderr)

hamburg.cpp: In function 'int main()':
hamburg.cpp:73:6: warning: unused variable 'yy1' [-Wunused-variable]
   73 |  int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 1e9;
      |      ^~~
hamburg.cpp:73:15: warning: unused variable 'yy2' [-Wunused-variable]
   73 |  int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 1e9;
      |               ^~~
hamburg.cpp:73:26: warning: unused variable 'yy3' [-Wunused-variable]
   73 |  int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 1e9;
      |                          ^~~
hamburg.cpp:73:35: warning: unused variable 'yy4' [-Wunused-variable]
   73 |  int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 1e9;
      |                                   ^~~
hamburg.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   66 |  scanf("%d%d", &n, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~
hamburg.cpp:68:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |   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...