QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#404751 | #4005. Frog | XUAN_ | WA | 1ms | 4052kb | C++14 | 2.3kb | 2024-05-04 17:00:54 | 2024-05-04 17:00:55 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define db double
using namespace std;
const int N = 1e5+7;
const db Pi = acos(-1.0),di=180.00;
template <typename T> inline void read(T &x){
T ch=getchar(),xx=1;x=0;
while(!isdigit(ch)) xx=ch=='-'?-1:xx,ch=getchar();
while(isdigit(ch)) x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
x*=xx;
}
template <typename T> void print(T x){
if(x<0) putchar('-'),x=-x;
if(x>9) print(x/10);
putchar(x%10+'0');
}
struct Node{
db x,y;
void rd(int a){
a=(a+360)%360;
x=cos(Pi*(db)a/di);
y=sin(Pi*(db)a/di);
}
Node operator + (const Node &a) const
{
Node res;
res.x=x+a.x;
res.y=y+a.y;
return res;
}
Node operator * (const db &a) const
{
Node res;
res.x=x*a;
res.y=y*a;
return res;
}
Node operator - (const Node &a) const
{
Node res;
res.x=x-a.x;
res.y=y-a.y;
return res;
}
void pr(){
printf("%.10lf %.10lf\n",x,y);
}
}ans[10],s,t,o;
db dis(Node a,Node b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
db k(Node a,Node b){
return (b.y-a.y)/(b.x-a.x);
}
int tot;
int ds,dt;
void solve(int dag){
tot=0;
ans[++tot]=s;
if(dag==0) return;
if(dag<=90){
Node mid=s+t;
ans[++tot]=mid*( ( (sqrt(1.0-dis(s,mid)*dis(s,mid))) +dis(o,mid)) /dis(o,mid));
}else if(dag<=131){
Node tt;
tt.rd(ds+90.0);
ans[++tot]=s+tt;
s=ans[tot];
Node mid=s+t;
mid.x*=0.5,mid.y*=0.5;
db len=sqrt(1.0-dis(s,mid)*dis(s,mid));
Node tmp;tmp.x=t.x;tmp.y=-1.0/k(s,t)*tmp.x;
tmp=tmp*(len/dis(o,tmp));
ans[++tot]=mid+tmp;
}else{
Node tt;
tt.rd(ds+90.0);
Node mid=s+tt;
ans[++tot]=mid-o;
s=tt;
ans[++tot]=s;
mid=s+t;
ans[++tot]=mid*( ( (sqrt(1.0-dis(s,mid)*dis(s,mid))) +dis(o,mid)) /dis(o,mid));
}
ans[++tot]=t;
}
int main(){
int T;
read(T);
o.x=o.y=0.0;
while(T--){
bool flag=1;
read(ds),read(dt);
int dlt=0;
if(dt>=ds) dlt=dt-ds;
else dlt=360-ds+dt;
if(dlt<=180) flag=0;
else swap(ds,dt),dlt=360-dlt;
s.rd(db(ds)),t.rd(db(dt));
solve(dt-ds);
print(tot-1),putchar('\n');
// for(int i=2;i<=tot;++i)
// {
// cout<<dis(ans[i],ans[i-1])<<endl;
// }
if(!flag) for(int i=1;i<=tot;++i) ans[i].pr();
else for(int i=tot;i;--i) ans[i].pr();
}
return 0;
}
/*
3
0 0
0 90
180 0
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4052kb
input:
3 0 0 0 90 180 0
output:
0 1.0000000000 0.0000000000 2 1.0000000000 0.0000000000 1.0000000000 1.0000000000 0.0000000000 1.0000000000 2 -1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000
result:
wrong answer Jump #1 went inside pillar. (Test case 3)