Submission #374593
Source Code Expand
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef pair<int,int> P;
D pi=acos(-1),eps=1e-8,EPS=1e-6;
int cnt=0;
D nowphi,nowr;
D gety(D rad){
cnt++;
D t=rad/pi*180.0;
printf("? %f\n",t); fflush(stdout);
double ymax; scanf("%lf", &ymax);
return ymax;
}
D getphi(D theta){
D a=theta+EPS,b=a+EPS;
D ya=gety(a),yb=gety(b);
if(ya<eps&&yb<eps){
nowr=0;
nowphi=0;
if(theta>pi) nowphi=2*pi;
// show(nowphi);
return nowphi;
}
D rs=ya;
D rc=(yb-ya)/EPS;
D r2=rs*rs+rc*rc;
D r=sqrt(r2);
D phi=-atan2(rs,rc)-(theta+EPS);
while(phi<-EPS) phi+=2*pi;
if(phi<0) phi=0;
// show(phi);
nowr=r,nowphi=phi;
return phi;
}
vector<P> ans;
int fix(D x){
D y=round(x);
if(abs(x-y)<1e-3) return (int)y;
assert(false);
}
int main(){
D theta=0;
// show(2*pi-atan2(1,1000)+EPS*2);
while(true){
/*D a=theta+EPS,b=a+EPS;
D ya=gety(a),yb=gety(b);
D rs=ya;
D rc=(yb-ya)/EPS;
D r2=rs*rs+rc*rc;
D r=sqrt(r2);
D phi=-atan2(rs,rc)-(theta+EPS);
while(phi<-EPS) phi+=2*pi;
if(phi<0) phi=0;*/
D phi=getphi(theta);
D ub=2*pi-2*EPS,lb=theta;
rep(ttt,30){
D m=(ub+lb)/2;
D phi2=getphi(m);
if(abs(phi-phi2)<EPS*100) lb=m;
else ub=m;
}
D phi0=nowphi,r0=nowr;
ans.pb(P(fix(r0*cos(phi0)),fix(r0*sin(phi0))));
// cout<<ans.back().fs<<" "<<ans.back().sc<<endl;
theta=ub+2*EPS;
if(theta>2*pi-atan2(1,1000)+EPS*2||cnt>700) break;
}
ans.pb(P(0,0));
reverse(all(ans));
printf("! %d\n",ans.size());
rep(i,ans.size()){
printf("! %d %d\n",ans[i].fs,ans[i].sc);
}
}
Submission Info
Submission Time
2015-03-29 17:59:06+0900
Task
H - 回すだけ
User
SAT3
Language
C++11 (GCC 4.9.2)
Score
0
Code Size
1890 Byte
Status
TLE
Exec Time
2034 ms
Memory
1276 KiB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:80:28: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<std::pair<int, int> >::size_type {aka long unsigned int}’ [-Wformat=]
printf("! %d\n",ans.size());
^
./Main.cpp: In function ‘D gety(D)’:
./Main.cpp:21:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
double ymax; scanf("%lf", &ymax);
^
Judge Result
Set Name
All
Score / Max Score
0 / 300
Status
Set Name
Test Cases
All
scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt, scrambled_19.txt, scrambled_20.txt, scrambled_21.txt, scrambled_22.txt, scrambled_23.txt, scrambled_24.txt, scrambled_25.txt, scrambled_26.txt, scrambled_27.txt, scrambled_28.txt, scrambled_29.txt
Case Name
Status
Exec Time
Memory
scrambled_00.txt
TLE
2031 ms
1128 KiB
scrambled_01.txt
TLE
2030 ms
1128 KiB
scrambled_02.txt
TLE
2033 ms
1128 KiB
scrambled_03.txt
TLE
2033 ms
1132 KiB
scrambled_04.txt
TLE
2032 ms
1180 KiB
scrambled_05.txt
TLE
2032 ms
1132 KiB
scrambled_06.txt
TLE
2032 ms
1200 KiB
scrambled_07.txt
TLE
2031 ms
1128 KiB
scrambled_08.txt
TLE
2033 ms
1276 KiB
scrambled_09.txt
TLE
2031 ms
1128 KiB
scrambled_10.txt
TLE
2031 ms
1128 KiB
scrambled_11.txt
TLE
2033 ms
1184 KiB
scrambled_12.txt
TLE
2033 ms
1136 KiB
scrambled_13.txt
TLE
2033 ms
1264 KiB
scrambled_14.txt
TLE
2032 ms
1124 KiB
scrambled_15.txt
TLE
2033 ms
1260 KiB
scrambled_16.txt
TLE
2033 ms
1188 KiB
scrambled_17.txt
TLE
2033 ms
1180 KiB
scrambled_18.txt
TLE
2032 ms
1132 KiB
scrambled_19.txt
TLE
2032 ms
1184 KiB
scrambled_20.txt
TLE
2033 ms
1100 KiB
scrambled_21.txt
TLE
2033 ms
1180 KiB
scrambled_22.txt
TLE
2031 ms
1148 KiB
scrambled_23.txt
TLE
2031 ms
1132 KiB
scrambled_24.txt
TLE
2032 ms
1184 KiB
scrambled_25.txt
TLE
2034 ms
1272 KiB
scrambled_26.txt
TLE
2033 ms
1276 KiB
scrambled_27.txt
TLE
2032 ms
1060 KiB
scrambled_28.txt
TLE
2032 ms
1188 KiB
scrambled_29.txt
TLE
2033 ms
1224 KiB