QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#825099 | #9770. Middle Point | ucup-team1134# | RE | 0ms | 3544kb | C++23 | 2.8kb | 2024-12-21 17:20:34 | 2024-12-21 17:20:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;
ll H,W;
ll dis(ll x,ll y){
ll res=0;
{
ll l=0,r=H,cn=0;
while(l!=x&&r!=x){
cn++;
ll m=(l+r)/2;
if(m<=x) l=m;
else r=m;
}
chmax(res,cn);
}
{
ll l=0,r=W,cn=0;
while(l!=y&&r!=y){
cn++;
ll m=(l+r)/2;
if(m<=y) l=m;
else r=m;
}
chmax(res,cn);
}
return res;
}
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
cin>>H>>W;
ll x,y;cin>>x>>y;
if((x==0||x==H)&&(y==0||y==W)){
cout<<0<<"\n";
return 0;
}
ll gh=gcd(H,x),gw=gcd(W,y);
H/=gh;
x/=gh;
W/=gw;
y/=gw;
if(H){
for(ll t=32;t>=0;t--){
if((1LL<<t)==H){
break;
}
if(t==0){
cout<<-1<<"\n";
return 0;
}
}
}
if(W){
for(ll t=32;t>=0;t--){
if((1LL<<t)==W){
break;
}
if(t==0){
cout<<-1<<"\n";
return 0;
}
}
}
vector<array<ll,4>> ans;
ll D=dis(x,y);
vector<pll> Z;
Z.pb(mp(0,0));
Z.pb(mp(0,W));
Z.pb(mp(H,0));
Z.pb(mp(H,W));
while(D){
for(auto [a,b]:Z){
ll c=x+x-a,d=y+y-b;
if(c<0||c>H||d<0||d>W) continue;
//cout<<c<<" "<<d<<" "<<dis(c,d)<<endl;
if(dis(c,d)==D-1){
ans.pb({a,b,c,d});
D--;
x=c;
y=d;
break;
}
}
}
reverse(all(ans));
cout<<si(ans)<<"\n";
for(auto [a,b,c,d]:ans){
cout<<a*gh<<" "<<b*gw<<" "<<c*gh<<" "<<d*gw<<"\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3500kb
input:
2 2 1 1
output:
1 0 0 2 2
result:
ok correct!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
8 8 5 0
output:
3 0 0 8 0 0 0 4 0 8 0 2 0
result:
ok correct!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
0 0 0 0
output:
0
result:
ok correct!
Test #4:
score: -100
Runtime Error
input:
2024 0 1012 0