QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#824880 | #9770. Middle Point | ucup-team5318# | ML | 0ms | 3872kb | C++14 | 1.5kb | 2024-12-21 16:20:37 | 2024-12-21 16:20:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
int n,m,ax,ay;
int lowbit(int x){return (x&-x);}
int cnt,ans[N][4];
void slv(int x,int y)
{
if(x==0 || x==n)
{
if(y==0 || y==m)return ;
if(lowbit(y)<=lowbit(m))
{
int l=0,r=m;
while(l<=r)
{
int mid=l+r>>1;
cnt++,ans[cnt][0]=x,ans[cnt][1]=l,ans[cnt][2]=x,ans[cnt][3]=r;
if(mid==y)break;
else if(mid<y)l=mid;
else r=mid;
}
return ;
}
else printf("-1\n"),exit(0);
}
else if(y==0 || y==m)
{
if(x==0 || x==n)return ;
if(lowbit(x)<=lowbit(n))
{
int l=0,r=n;
while(l<=r)
{
int mid=l+r>>1;
cnt++,ans[cnt][0]=l,ans[cnt][1]=y,ans[cnt][2]=r,ans[cnt][3]=y;
if(mid==x)break;
else if(mid<x)l=mid;
else r=mid;
}
return ;
}
else printf("-1\n"),exit(0);
}
if(x*2<=n && y*2<=m)
{
slv(x*2,y*2);
cnt++,ans[cnt][0]=0,ans[cnt][1]=0,ans[cnt][2]=x*2,ans[cnt][3]=y*2;
}
else if(x*2<=n && m-2*(m-y)>=0)
{
slv(x*2,m-2*(m-y));
cnt++,ans[cnt][0]=0,ans[cnt][1]=m,ans[cnt][2]=x*2,ans[cnt][3]=m-2*(m-y);
}
else if(n-2*(n-x)>=0 && y*2<=m)
{
slv(n-2*(n-x),y*2);
cnt++,ans[cnt][0]=n,ans[cnt][1]=0,ans[cnt][2]=n-2*(n-x),ans[cnt][3]=y*2;
}
else
{
slv(n-2*(n-x),m-2*(m-y));
cnt++,ans[cnt][0]=n,ans[cnt][1]=m,ans[cnt][2]=n-2*(n-x),ans[cnt][3]=m-2*(m-y);
}
}
int main()
{
scanf("%d %d",&n,&m);
scanf("%d %d",&ax,&ay);
slv(ax,ay);
printf("%d\n",cnt);
for(int i=1;i<=cnt;i++)printf("%d %d %d %d\n",ans[i][0],ans[i][1],ans[i][2],ans[i][3]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
2 2 1 1
output:
1 0 0 2 2
result:
ok correct!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
8 8 5 0
output:
3 0 0 8 0 4 0 8 0 4 0 6 0
result:
ok correct!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0 0 0 0
output:
0
result:
ok correct!
Test #4:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
2024 0 1012 0
output:
1 0 0 2024 0
result:
ok correct!
Test #5:
score: -100
Memory Limit Exceeded
input:
2024 2024 2023 2023