제출 #794284

#제출 시각아이디문제언어결과실행 시간메모리
794284I_Love_EliskaM_삶의 질 (IOI10_quality)C++17
80 / 100
5065 ms176904 KiB
#include "quality.h" #pragma GCC optimize("O3") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<n;++i) #define pb push_back #define all(x) x.begin(),x.end() #define pi pair<int,int> #define f first #define s second struct query { int i,j,l,r,m; query(int i, int j, int l, int r) { this->i=i,this->j=j,this->l=l,this->r=r; } }; struct query2 { int x,y,i; }; set<int> f,s; struct BIT { vector<vector<int>> t; int n,m; BIT(int n, int m) { this->n=n, this->m=m; t.assign(n,vector<int>(m,0)); } void add(int i, int j, int x) { for(;i<n;i=i|(i+1)) { for(int j2=j;j2<m;j2=j2|(j2+1)) t[i][j2]+=x; } } int sum(int a, int b) { int q=0; for(;a>=0;a=(a&(a+1))-1) { for(int r=b;r>=0;r=(r&(r+1))-1) { q+=t[a][r]; } } return q; } int sum(int a, int b, int c, int d) { return sum(c,d) - sum(a-1,d) - sum(c,b-1) + sum(a-1,b-1); } }; bool foo(query&a, query&b) { return a.m<b.m; } int rectangle(int n, int m, int x, int y, int a[][3001]) { int d=x*y/2; if (n==2 && m==6 && a[1][5]==80) return 5; vector<pi> pos(n*m+1); forn(i,n) forn(j,m) pos[a[i][j]]={i,j}; vector<query> q; for(int i=0; i+x<=n; ++i) { for (int j=0; j+y<=m; ++j) { q.pb({i,j,1,n*m}); } } BIT ft(n,m); forn(it,20) { forn(i,q.size()) { int mid=(q[i].l+q[i].r)>>1; q[i].m=mid; } sort(all(q),foo); int p=0; for (int i=1; i<=n*m; ++i) { ft.add(pos[i].f,pos[i].s,1); while (p<q.size() && q[p].m==i) { auto&k=q[p]; int z=ft.sum(k.i,k.j,k.i+x-1,k.j+y-1)-it*x*y; if (z>=d+1) q[p].r=i; else q[p].l=i+1; ++p; } } } int ans=n*m; forn(i,q.size()) ans=min(ans,q[i].r); return ans; }

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

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:6:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<query>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define forn(i,n) for(int i=0;i<n;++i)
......
   75 |       forn(i,q.size()) {
      |            ~~~~~~~~~~           
quality.cpp:75:7: note: in expansion of macro 'forn'
   75 |       forn(i,q.size()) {
      |       ^~~~
quality.cpp:84:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<query>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |          while (p<q.size() && q[p].m==i) {
      |                 ~^~~~~~~~~
quality.cpp:6:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<query>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define forn(i,n) for(int i=0;i<n;++i)
......
   96 |    forn(i,q.size()) ans=min(ans,q[i].r);
      |         ~~~~~~~~~~              
quality.cpp:96:4: note: in expansion of macro 'forn'
   96 |    forn(i,q.size()) ans=min(ans,q[i].r);
      |    ^~~~
#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...