QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#19208 | #1819. Cleaning Robot | foreverlasting# | WA | 318ms | 414068kb | C++20 | 4.9kb | 2022-01-28 14:31:26 | 2022-05-06 04:27:36 |
Judging History
answer
//2022.1.28 by ljz
//email [email protected]
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define res int
#define LL long long
#define Inf 0x3f3f3f3f
#define sup 0x7fffffff
#define inf 0x3f3f3f3f
#define INF 2000000000000000000
//#define unl __int128
#define eps 1e-10
#define RG
#define db double
#define pc(x) __builtin_popcount(x)
#define ctz(x) __builtin_ctz(x)
//#define pc(x) __builtin_popcountll(x)
typedef pair<int,int> Pair;
//#define poly vector<int>
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define uint unsigned int
#define lowbit(x) ((x)&-(x))
#define gc getchar
#define ld long db
//template <class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//inline int gc() {
// static char buf[100000],*p1,*p2;
// return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//char sr[1<<21],z[20];
//int C=-1,Z=0;
//inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
//inline void print(RG LL x){
// if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
// while(z[++Z]=x%10+48,x/=10);
// while(sr[++C]=z[Z],--Z);
//}
template <typename T> inline void Read(T &x) {
res c=gc();
bool f=false;
for(x=0;!isdigit(c);c=gc())if(c=='-')f=true;
for(;isdigit(c);c=gc())x=x*10+c-'0';
if(f)x=-x;
}
inline int read() {
res s=0,ch=gc(),w=1;
while(ch<'0'||ch>'9'){
if(ch=='-')w=-1;
else if(ch==EOF)break;
ch=gc();
}
while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
return s*w;
}
inline LL Read() {
RG LL s=0;
res ch=gc(),w=1;
while(ch<'0'||ch>'9'){
if(ch=='-')w=-1;
else if(ch==EOF)break;
ch=gc();
}
while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
return s*w;
}
inline void write(RG __int128 x){
if(x>10)write(x/10);
putchar(int(x%10)+'0');
}
const int kcz=998244353;
const int G=3,GI=332748118;
//inline void add(res &x,const res &y){
// x+=y,x>=kcz?x-=kcz:1;
//}
//inline int Add(const res &x,const res &y){
// return x+y>=kcz?x+y-kcz:x+y;
//}
//inline int mul(const res &x,const res &y){
// return int(1ll*x*y%kcz);
//}
#define add(x,y) ((x)+=(y),(x)>=kcz?(x)-=kcz:1)
#define Add(x,y) ((x)+(y)>=kcz?(x)+(y)-kcz:(x)+(y))
#define mul(x,y) (int)((LL)(x)*(y)%kcz)
#define Mul(x,y,d) (int)((ull)(x)*(y)/(d)%kcz)
inline int qpow(res x,res y=kcz-2){
res ret=1;
while(y){
if(y&1)ret=mul(ret,x);
x=mul(x,x),y>>=1;
}
return ret;
}
inline int qpow(res x,res y,const res &ljc){
res ret=1;
while(y){
if(y&1)ret=(int)(1ll*ret*x%ljc);
x=(int)(1ll*x*x%ljc),y>>=1;
}
return ret;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//cloclim_t start=cloclim();
//inline void clim(){
// if(1.0*(cloclim()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
//2022.1.28 by ljz
//email [email protected]
//if you find any bug in my code
//please tell me
const int N=5e6+10;
namespace MAIN{
int n,m,k;
vector<int> A[N],B[N],C[N];
inline void MAIN(){
n=read(),m=read(),k=read();
for(res i=0;i<=n+1;i++)A[i].resize(m+2),C[i].resize(m+2);
for(res i=1;i<=k;i++){
res x=read(),y=read();
A[x][y]=C[x][y]=1;
}
for(res i=1;i<=n;i++)for(res j=1;j<=m;j++){
A[i][j]+=A[i-1][j]+A[i][j-1]-A[i-1][j-1];
}
res l=1,r=min(n,m),ret=0;
while(l<=r){
res mid=(l+r)>>1;
for(res i=0;i<=n+1;i++)vector<int>(m+2).swap(B[i]);
for(res i=1;i<=n;i++){
for(res j=1;j<=m;j++){
if(i+mid-1<=n&&j+mid-1<=m){
res t=A[i+mid-1][j+mid-1]-A[i+mid-1][j-1]-A[i-1][j+mid-1]+A[i-1][j-1];
// if(mid==3)printf("%d %d %d\n",i,j,t);
if(!t)B[i][j]++,B[i+mid][j]--,B[i][j+mid]--,B[i+mid][j+mid]++;
}
}
}
for(res i=1;i<=n;i++)for(res j=1;j<=m;j++)B[i][j]+=B[i-1][j]+B[i][j-1]-B[i-1][j-1];
res fl=0;
for(res i=1;i<=n;i++){
for(res j=1;j<=m;j++){
if(C[i][j])continue;
// if(mid==3)printf("%d %d %d\n",i,j,B[i][j]);
if(!B[i][j]){fl=1;break;}
}
if(fl)break;
}
if(fl)r=mid-1;
else l=mid+1,ret=mid;
}
printf("%d\n",ret);
}
}
int main(){
// srand(time(0));
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
res Case=1;
for(res T=1;T<=Case;T++)MAIN::MAIN();
// Ot();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 68ms
memory: 355272kb
input:
10 7 1 8 3
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 318ms
memory: 414032kb
input:
2236 2236 2214 28 1255 389 2175 730 592 1360 977 1225 752 1403 1798 1518 1381 147 745 659 249 951 1475 1826 1951 691 1033 81 1458 1487 1946 2106 1395 1995 629 470 891 1902 822 2210 2001 441 2130 1198 1539 2027 1101 215 1149 205 420 379 2104 308 1225 859 109 1417 2078 1764 376 1772 5 335 1113 917 118...
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 301ms
memory: 413980kb
input:
2236 2236 2143 228 686 129 801 1105 382 2196 1919 2082 777 1672 268 174 916 234 491 1235 274 1645 1849 1114 1173 1351 1677 1294 1365 1059 197 611 1715 1769 1395 885 1902 1190 1304 1039 779 610 124 881 662 22 1664 239 1283 2218 2031 169 1417 291 143 228 1837 1518 2013 747 359 1997 1030 73 153 614 488...
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 265ms
memory: 414068kb
input:
2236 2236 63774 369 1861 1156 2150 1895 160 546 1944 1688 645 49 1888 430 973 1602 30 1988 971 1120 1307 322 1524 1559 1070 558 1147 973 1965 572 923 370 646 1436 1982 132 681 1410 308 1812 982 2191 2112 1311 396 1067 1330 659 477 873 881 1766 508 2091 1875 895 716 2058 1237 1374 1005 2183 1514 227 ...
output:
8
result:
ok answer is '8'
Test #5:
score: -100
Wrong Answer
time: 291ms
memory: 414036kb
input:
2236 2236 27245 1371 170 575 488 1594 575 1537 77 491 1580 1761 764 783 1265 242 923 893 71 1455 671 114 1289 1901 1481 1962 1160 861 2198 1055 89 2019 1481 1012 1415 1023 92 421 2018 1788 2006 1559 263 1387 1496 1556 479 166 1085 1368 2156 2076 2156 1028 617 919 146 698 1544 1730 2111 871 1478 768 ...
output:
20
result:
wrong answer expected '16', found '20'