fork(8) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <fstream>
  4. #include <string>
  5. #include <vector>
  6. #include <deque>
  7. #include <queue>
  8. #include <stack>
  9. #include <set>
  10. #include <map>
  11. #include <algorithm>
  12. #include <functional>
  13. #include <utility>
  14. #include <bitset>
  15. #include <cmath>
  16. #include <cstdlib>
  17. #include <ctime>
  18. #include <cstdio>
  19.  
  20. using namespace std;
  21.  
  22. #define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
  23. #define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
  24.  
  25. #define INF 1.0E+9
  26. struct point {double x,y;};
  27.  
  28. int M,N;
  29. point P[110];
  30. point pin[110];
  31.  
  32. int sz;
  33. int st[10010];
  34.  
  35. void add(int x){
  36. st[sz] = x;
  37. sz++;
  38. if(sz >= 2 && st[sz-1] == st[sz-2]) sz -= 2;
  39. }
  40.  
  41. int K;
  42. double x[10010],y[10010];
  43. int sign[10010];
  44. double dp[10010];
  45.  
  46. void add2(point P, int type){
  47. if(K > 0 && x[K-1] == P.x){
  48. sign[K-1] = 0;
  49. } else {
  50. x[K] = P.x;
  51. y[K] = P.y;
  52. sign[K] = type;
  53. K++;
  54. }
  55. }
  56.  
  57. double calc_dp(void){
  58. int i,j;
  59.  
  60. dp[0] = 0.0;
  61.  
  62. for(i=1;i<K;i++){
  63. dp[i] = INF;
  64. double high = INF, low = -INF;
  65.  
  66. for(j=i-1;j>=0;j--){
  67. if((x[j] < x[j+1]) != (x[i-1] < x[i])) break;
  68.  
  69. double c = (y[i] - y[j]) / (x[i] - x[j]);
  70. if(x[i-1] < x[i]){
  71. if(sign[j] >= 0) high = min(high, c);
  72. if(sign[j] <= 0) low = max(low, c);
  73. } else {
  74. if(sign[j] <= 0) high = min(high, c);
  75. if(sign[j] >= 0) low = max(low, c);
  76. }
  77.  
  78. if(high < low) break;
  79.  
  80. if(low <= c && c <= high){
  81. double tmp = dp[j] + sqrt((x[i]-x[j]) * (x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]));
  82. dp[i] = min(dp[i], tmp);
  83. }
  84. }
  85. }
  86.  
  87. return dp[K-1];
  88. }
  89.  
  90. double func(void){
  91. int i,j;
  92.  
  93. sz = 0;
  94. REP(i,M-1){
  95. point Q = P[i], R = P[i+1];
  96. REP(j,N) if(Q.x < pin[j].x && pin[j].x < R.x){
  97. double y = Q.y + (R.y - Q.y) / (R.x - Q.x) * (pin[j].x - Q.x);
  98. if(y < pin[j].y) add(j); else add(j+N);
  99. }
  100. for(j=N-1;j>=0;j--) if(R.x < pin[j].x && pin[j].x < Q.x){
  101. double y = Q.y + (R.y - Q.y) / (R.x - Q.x) * (pin[j].x - Q.x);
  102. if(y < pin[j].y) add(j); else add(j+N);
  103. }
  104. }
  105.  
  106. K = 0;
  107. add2(P[0], 0);
  108. REP(i,sz) add2(pin[st[i] % N], ((st[i] < N) ? -1 : 1));
  109. add2(P[M-1], 0);
  110.  
  111. calc_dp();
  112. return dp[K-1];
  113. }
  114.  
  115. point rotate(point P){
  116. double x = P.x * cos(0.01) - P.y * sin(0.01);
  117. double y = P.x * sin(0.01) + P.y * cos(0.01);
  118. point Q = {x, y};
  119. return Q;
  120. }
  121.  
  122. int main(void){
  123. int i,j;
  124.  
  125. while(cin >> M >> N){
  126. if(M == 0 && N == 0) break;
  127.  
  128. REP(i,M) cin >> P[i].x >> P[i].y;
  129. REP(i,N) cin >> pin[i].x >> pin[i].y;
  130.  
  131. REP(i,M) P[i] = rotate(P[i]);
  132. REP(i,N) pin[i] = rotate(pin[i]);
  133. REP(i,N) REP(j,N-1) if(pin[j].x > pin[j+1].x) swap(pin[j], pin[j+1]);
  134.  
  135. double ans = func();
  136. printf("%.9f\n", ans);
  137. }
  138.  
  139. return 0;
  140. }
  141.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: \35
#include <iostream>
^
Main.java:1: error: class, interface, or enum expected
#include <iostream>
         ^
Main.java:2: error: illegal character: \35
#include <sstream>
^
Main.java:3: error: illegal character: \35
#include <fstream>
^
Main.java:4: error: illegal character: \35
#include <string>
^
Main.java:5: error: illegal character: \35
#include <vector>
^
Main.java:6: error: illegal character: \35
#include <deque>
^
Main.java:7: error: illegal character: \35
#include <queue>
^
Main.java:8: error: illegal character: \35
#include <stack>
^
Main.java:9: error: illegal character: \35
#include <set>
^
Main.java:10: error: illegal character: \35
#include <map>
^
Main.java:11: error: illegal character: \35
#include <algorithm>
^
Main.java:12: error: illegal character: \35
#include <functional>
^
Main.java:13: error: illegal character: \35
#include <utility>
^
Main.java:14: error: illegal character: \35
#include <bitset>
^
Main.java:15: error: illegal character: \35
#include <cmath>
^
Main.java:16: error: illegal character: \35
#include <cstdlib>
^
Main.java:17: error: illegal character: \35
#include <ctime>
^
Main.java:18: error: illegal character: \35
#include <cstdio>
^
Main.java:22: error: illegal character: \35
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
^
Main.java:22: error: class, interface, or enum expected
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
        ^
Main.java:22: error: class, interface, or enum expected
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
                           ^
Main.java:22: error: class, interface, or enum expected
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
                                        ^
Main.java:23: error: illegal character: \35
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
^
Main.java:23: error: class, interface, or enum expected
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
                                                               ^
Main.java:23: error: class, interface, or enum expected
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
                                                                              ^
Main.java:25: error: illegal character: \35
#define INF 1.0E+9
^
Main.java:26: error: class, interface, or enum expected
struct point {double x,y;};
                         ^
Main.java:28: error: class, interface, or enum expected
int M,N;
^
Main.java:29: error: class, interface, or enum expected
point P[110];
^
Main.java:30: error: class, interface, or enum expected
point pin[110];
^
Main.java:32: error: class, interface, or enum expected
int sz;
^
Main.java:33: error: class, interface, or enum expected
int st[10010];
^
Main.java:35: error: class, interface, or enum expected
void add(int x){
^
Main.java:37: error: class, interface, or enum expected
	sz++;
	^
Main.java:38: error: class, interface, or enum expected
	if(sz >= 2 && st[sz-1] == st[sz-2]) sz -= 2;
	^
Main.java:39: error: class, interface, or enum expected
}
^
Main.java:42: error: class, interface, or enum expected
double x[10010],y[10010];
^
Main.java:43: error: class, interface, or enum expected
int sign[10010];
^
Main.java:44: error: class, interface, or enum expected
double dp[10010];
^
Main.java:46: error: class, interface, or enum expected
void add2(point P, int type){
^
Main.java:49: error: class, interface, or enum expected
	} else {
	^
Main.java:51: error: class, interface, or enum expected
		y[K] = P.y;
		^
Main.java:52: error: class, interface, or enum expected
		sign[K] = type;
		^
Main.java:53: error: class, interface, or enum expected
		K++;
		^
Main.java:54: error: class, interface, or enum expected
	}
	^
Main.java:60: error: class, interface, or enum expected
	dp[0] = 0.0;
	^
Main.java:62: error: class, interface, or enum expected
	for(i=1;i<K;i++){
	^
Main.java:62: error: class, interface, or enum expected
	for(i=1;i<K;i++){
	        ^
Main.java:62: error: class, interface, or enum expected
	for(i=1;i<K;i++){
	            ^
Main.java:64: error: class, interface, or enum expected
		double high = INF, low = -INF;
		^
Main.java:66: error: class, interface, or enum expected
		for(j=i-1;j>=0;j--){
		^
Main.java:66: error: class, interface, or enum expected
		for(j=i-1;j>=0;j--){
		          ^
Main.java:66: error: class, interface, or enum expected
		for(j=i-1;j>=0;j--){
		               ^
Main.java:69: error: class, interface, or enum expected
			double c = (y[i] - y[j]) / (x[i] - x[j]);
			^
Main.java:70: error: class, interface, or enum expected
			if(x[i-1] < x[i]){
			^
Main.java:72: error: class, interface, or enum expected
				if(sign[j] <= 0) low = max(low, c);
				^
Main.java:73: error: class, interface, or enum expected
			} else {
			^
Main.java:75: error: class, interface, or enum expected
				if(sign[j] >= 0) low = max(low, c);
				^
Main.java:76: error: class, interface, or enum expected
			}
			^
Main.java:80: error: class, interface, or enum expected
			if(low <= c && c <= high){
			^
Main.java:82: error: class, interface, or enum expected
				dp[i] = min(dp[i], tmp);
				^
Main.java:83: error: class, interface, or enum expected
			}
			^
Main.java:88: error: class, interface, or enum expected
}
^
Main.java:93: error: class, interface, or enum expected
	sz = 0;
	^
Main.java:94: error: class, interface, or enum expected
	REP(i,M-1){
	^
Main.java:96: error: class, interface, or enum expected
		REP(j,N) if(Q.x < pin[j].x && pin[j].x < R.x){
		^
Main.java:98: error: class, interface, or enum expected
			if(y < pin[j].y) add(j); else add(j+N);
			^
Main.java:98: error: class, interface, or enum expected
			if(y < pin[j].y) add(j); else add(j+N);
			                         ^
Main.java:99: error: class, interface, or enum expected
		}
		^
Main.java:100: error: class, interface, or enum expected
		for(j=N-1;j>=0;j--) if(R.x < pin[j].x && pin[j].x < Q.x){
		          ^
Main.java:100: error: class, interface, or enum expected
		for(j=N-1;j>=0;j--) if(R.x < pin[j].x && pin[j].x < Q.x){
		               ^
Main.java:102: error: class, interface, or enum expected
			if(y < pin[j].y) add(j); else add(j+N);
			^
Main.java:102: error: class, interface, or enum expected
			if(y < pin[j].y) add(j); else add(j+N);
			                         ^
Main.java:103: error: class, interface, or enum expected
		}
		^
Main.java:107: error: class, interface, or enum expected
	add2(P[0], 0);
	^
Main.java:108: error: class, interface, or enum expected
	REP(i,sz) add2(pin[st[i] % N], ((st[i] < N) ? -1 : 1));
	^
Main.java:109: error: class, interface, or enum expected
	add2(P[M-1], 0);
	^
Main.java:111: error: class, interface, or enum expected
	calc_dp();
	^
Main.java:112: error: class, interface, or enum expected
	return dp[K-1];
	^
Main.java:113: error: class, interface, or enum expected
}
^
Main.java:117: error: class, interface, or enum expected
	double y = P.x * sin(0.01) + P.y * cos(0.01);
	^
Main.java:118: error: class, interface, or enum expected
	point Q = {x, y};
	^
Main.java:119: error: class, interface, or enum expected
	return Q;
	^
Main.java:120: error: class, interface, or enum expected
}
^
Main.java:125: error: class, interface, or enum expected
	while(cin >> M >> N){
	^
Main.java:128: error: class, interface, or enum expected
		REP(i,M) cin >> P[i].x >> P[i].y;
		^
Main.java:129: error: class, interface, or enum expected
		REP(i,N) cin >> pin[i].x >> pin[i].y;
		^
Main.java:131: error: class, interface, or enum expected
		REP(i,M) P[i] = rotate(P[i]);
		^
Main.java:132: error: class, interface, or enum expected
		REP(i,N) pin[i] = rotate(pin[i]);
		^
Main.java:133: error: class, interface, or enum expected
		REP(i,N) REP(j,N-1) if(pin[j].x > pin[j+1].x) swap(pin[j], pin[j+1]);
		^
Main.java:135: error: class, interface, or enum expected
		double ans = func();
		^
Main.java:136: error: class, interface, or enum expected
		printf("%.9f\n", ans);
		^
Main.java:137: error: class, interface, or enum expected
	}
	^
Main.java:140: error: class, interface, or enum expected
}
^
95 errors
stdout
Standard output is empty