QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#404740 | #4005. Frog | XUAN_ | WA | 13ms | 4088kb | C++14 | 2.3kb | 2024-05-04 16:23:15 | 2024-05-04 16:23:15 |
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);
if(dt-ds<=180 && dt-ds>=0) flag=0;
else swap(ds,dt);
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
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4060kb
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 4 -1.0000000000 0.0000000000 -1.0000000000 1.0000000000 0.0000000000 1.0000000000 1.0000000000 1.0000000000 1.0000000000 0.0000000000
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 13ms
memory: 4088kb
input:
10000 194 96 89 164 139 41 323 35 185 221 0 275 53 116 233 79 209 91 236 12 94 291 332 293 207 31 133 329 60 114 1 91 273 103 69 193 220 303 100 118 42 15 331 201 26 103 347 292 184 148 307 197 84 326 52 224 257 27 3 99 310 26 138 288 112 17 206 159 302 104 58 121 276 268 236 134 281 173 147 128 72 ...
output:
3 -0.9702957263 -0.2419218956 -1.8513236931 0.2311422879 -1.0990503586 0.8899934321 -0.1045284633 0.9945218954 2 0.0174524064 0.9998476952 -0.9438092984 1.2754850630 -0.9612616959 0.2756373558 3 -0.7547095802 0.6560590290 -0.8725349688 1.6490933576 0.0986505512 1.4107686092 0.7547095802 0.6560590290...
result:
wrong answer Jump #1 went inside pillar. (Test case 4)