답안 #211252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211252 2020-03-19T19:03:19 Z Lawliet Scissors and Tape (CEOI19_scissors) C++17
30 / 100
1000 ms 106112 KB
#include <bits/stdc++.h>

using namespace std;

struct point
{
	double x, y;

	point operator + (point a) { return point( x + a.x , y + a.y ); }

	bool operator != (point a) { return ( x != a.x ) || ( y != a.y ); }
	bool operator == (point a) { return ( x == a.x ) && ( y == a.y ); }

	point(double x, double y) : x(x), y(y) {}
};

int globalInd;

vector< point > S;
vector< point > T;

vector< point > readPolygon()
{
	int sz;
	scanf("%d",&sz);

	vector< point > ans;

	for(int i = 1 ; i <= sz ; i++)
	{
		double x, y;
		scanf("%lf %lf",&x,&y);

		ans.push_back( point( x , y ) );
	}

	return ans;
}

void printPolygon(vector< point > v)
{
	printf("%d ",(int) v.size());

	for(int i = 0 ; i < (int) v.size() ; i++)
		printf("%.12f %.12f ",v[i].x,v[i].y);

	printf("\n");
}

void tape(vector<int> ind)
{
	globalInd++;

	printf("tape\n");

	printf("%d ",(int) ind.size());

	for(int i = 0 ; i < (int) ind.size() ; i++)
		printf("%d ",ind[i]);

	printf("\n");
}

void scissors(int k, int qtd)
{
	printf("scissors\n");
	printf("%d %d\n",k,qtd);
}

void transform(vector<point> s, vector<point> t, int& curInd)
{
	if( s[0] != t[0] )
	{
		tape( vector<int>( 1 , curInd ) );

		double dx = t[0].x - s[0].x;
		double dy = t[0].y - s[0].y;

		point d( dx , dy );

		for(int i = 0 ; i < s.size() ; i++)
			s[i] = s[i] + d;

		printPolygon( s );
		printPolygon( s );

		curInd = globalInd;
	}

	if( s[2] == t[2] ) return;

	scissors( curInd , 2 );

	vector< point > up;
	vector< point > down;
	vector< point > equal;

	int minX = min( s[2].x , t[2].x );
	int maxX = max( s[2].x , t[2].x );
	int minY = min( s[2].y , t[2].y );
	int maxY = max( s[2].y , t[2].y );

	equal.push_back( s[0] );
	equal.push_back( point( minX , s[0].y ) );
	equal.push_back( point( minX , minY ) );
	equal.push_back( point( s[0].x , minY ) );

	printPolygon( equal );
	int indEqual = ++globalInd;

	up.push_back( point( s[0].x , minY ) );
	up.push_back( point( minX , minY ) );
	up.push_back( point( minX , maxY ) );
	up.push_back( point( s[0].x , maxY ) );

	down.push_back( point( minX , s[0].y ) );
	down.push_back( point( maxX , s[0].y ) );
	down.push_back( point( maxX , minY ) );
	down.push_back( point( minX , minY ) );

	vector< point > newS = up;
	vector< point > newT = down;

	if( s[2].x > t[2].x ) swap( newS , newT );

	printPolygon( newS );
	int indNewS = ++globalInd;

	transform( newS , newT , indNewS );

	vector< int > aux;
	aux.push_back( indEqual );
	aux.push_back( indNewS );

	tape( aux );

	printPolygon( equal );
	printPolygon( newT );
	printPolygon( t );

	curInd = globalInd;
}

int main()
{
	S = readPolygon();
	T = readPolygon();

	int ind = 0;
	transform( S , T , ind );
}

Compilation message

scissors.cpp: In function 'void transform(std::vector<point>, std::vector<point>, int&)':
scissors.cpp:81:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0 ; i < s.size() ; i++)
                   ~~^~~~~~~~~~
scissors.cpp: In function 'std::vector<point> readPolygon()':
scissors.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&sz);
  ~~~~~^~~~~~~~~~
scissors.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf %lf",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
2 Correct 6 ms 384 KB used 36 vertices, largest error was 0.00000000800000
3 Correct 6 ms 384 KB used 92 vertices, largest error was 0.00000000800000
4 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
5 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000900000
6 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
7 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
8 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
9 Correct 5 ms 288 KB used 36 vertices, largest error was 0.00000000800000
10 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
2 Correct 5 ms 256 KB used 92 vertices, largest error was 0.00000000800000
3 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000004000000
4 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000004000000
5 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
6 Correct 5 ms 384 KB used 232 vertices, largest error was 0.00000004000000
7 Correct 6 ms 384 KB used 204 vertices, largest error was 0.00000002400000
8 Correct 7 ms 384 KB used 1324 vertices, largest error was 0.00000002500000
9 Correct 5 ms 256 KB used 64 vertices, largest error was 0.00000004000000
10 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002500000
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
2 Correct 6 ms 384 KB used 36 vertices, largest error was 0.00000000800000
3 Correct 6 ms 384 KB used 92 vertices, largest error was 0.00000000800000
4 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
5 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000900000
6 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
7 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
8 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
9 Correct 5 ms 288 KB used 36 vertices, largest error was 0.00000000800000
10 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
11 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
12 Correct 5 ms 256 KB used 92 vertices, largest error was 0.00000000800000
13 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000004000000
14 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000004000000
15 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
16 Correct 5 ms 384 KB used 232 vertices, largest error was 0.00000004000000
17 Correct 6 ms 384 KB used 204 vertices, largest error was 0.00000002400000
18 Correct 7 ms 384 KB used 1324 vertices, largest error was 0.00000002500000
19 Correct 5 ms 256 KB used 64 vertices, largest error was 0.00000004000000
20 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002500000
21 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000002500000
22 Correct 6 ms 384 KB used 764 vertices, largest error was 0.00000002500000
23 Correct 6 ms 384 KB used 680 vertices, largest error was 0.00000002500000
24 Correct 5 ms 384 KB used 568 vertices, largest error was 0.00000002500000
25 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
26 Correct 5 ms 384 KB used 316 vertices, largest error was 0.00000002400000
27 Correct 6 ms 384 KB used 596 vertices, largest error was 0.00000004000000
28 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000002500000
29 Correct 5 ms 384 KB used 344 vertices, largest error was 0.00000002500000
30 Correct 9 ms 512 KB used 2304 vertices, largest error was 0.00000004000000
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1100 ms 79188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1099 ms 106112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
2 Correct 6 ms 384 KB used 36 vertices, largest error was 0.00000000800000
3 Correct 6 ms 384 KB used 92 vertices, largest error was 0.00000000800000
4 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
5 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000900000
6 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
7 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
8 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
9 Correct 5 ms 288 KB used 36 vertices, largest error was 0.00000000800000
10 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
11 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
12 Correct 5 ms 256 KB used 92 vertices, largest error was 0.00000000800000
13 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000004000000
14 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000004000000
15 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
16 Correct 5 ms 384 KB used 232 vertices, largest error was 0.00000004000000
17 Correct 6 ms 384 KB used 204 vertices, largest error was 0.00000002400000
18 Correct 7 ms 384 KB used 1324 vertices, largest error was 0.00000002500000
19 Correct 5 ms 256 KB used 64 vertices, largest error was 0.00000004000000
20 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002500000
21 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000002500000
22 Correct 6 ms 384 KB used 764 vertices, largest error was 0.00000002500000
23 Correct 6 ms 384 KB used 680 vertices, largest error was 0.00000002500000
24 Correct 5 ms 384 KB used 568 vertices, largest error was 0.00000002500000
25 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
26 Correct 5 ms 384 KB used 316 vertices, largest error was 0.00000002400000
27 Correct 6 ms 384 KB used 596 vertices, largest error was 0.00000004000000
28 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000002500000
29 Correct 5 ms 384 KB used 344 vertices, largest error was 0.00000002500000
30 Correct 9 ms 512 KB used 2304 vertices, largest error was 0.00000004000000
31 Execution timed out 1100 ms 79188 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
2 Correct 6 ms 384 KB used 36 vertices, largest error was 0.00000000800000
3 Correct 6 ms 384 KB used 92 vertices, largest error was 0.00000000800000
4 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
5 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000900000
6 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
7 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
8 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
9 Correct 5 ms 288 KB used 36 vertices, largest error was 0.00000000800000
10 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
11 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
12 Correct 5 ms 256 KB used 92 vertices, largest error was 0.00000000800000
13 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000004000000
14 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000004000000
15 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
16 Correct 5 ms 384 KB used 232 vertices, largest error was 0.00000004000000
17 Correct 6 ms 384 KB used 204 vertices, largest error was 0.00000002400000
18 Correct 7 ms 384 KB used 1324 vertices, largest error was 0.00000002500000
19 Correct 5 ms 256 KB used 64 vertices, largest error was 0.00000004000000
20 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002500000
21 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000002500000
22 Correct 6 ms 384 KB used 764 vertices, largest error was 0.00000002500000
23 Correct 6 ms 384 KB used 680 vertices, largest error was 0.00000002500000
24 Correct 5 ms 384 KB used 568 vertices, largest error was 0.00000002500000
25 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
26 Correct 5 ms 384 KB used 316 vertices, largest error was 0.00000002400000
27 Correct 6 ms 384 KB used 596 vertices, largest error was 0.00000004000000
28 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000002500000
29 Correct 5 ms 384 KB used 344 vertices, largest error was 0.00000002500000
30 Correct 9 ms 512 KB used 2304 vertices, largest error was 0.00000004000000
31 Execution timed out 1100 ms 79188 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
2 Correct 6 ms 384 KB used 36 vertices, largest error was 0.00000000800000
3 Correct 6 ms 384 KB used 92 vertices, largest error was 0.00000000800000
4 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
5 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000900000
6 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
7 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
8 Correct 5 ms 384 KB used 92 vertices, largest error was 0.00000000800000
9 Correct 5 ms 288 KB used 36 vertices, largest error was 0.00000000800000
10 Correct 5 ms 256 KB used 36 vertices, largest error was 0.00000000800000
11 Correct 5 ms 384 KB used 120 vertices, largest error was 0.00000000800000
12 Correct 5 ms 256 KB used 92 vertices, largest error was 0.00000000800000
13 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000004000000
14 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000004000000
15 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
16 Correct 5 ms 384 KB used 232 vertices, largest error was 0.00000004000000
17 Correct 6 ms 384 KB used 204 vertices, largest error was 0.00000002400000
18 Correct 7 ms 384 KB used 1324 vertices, largest error was 0.00000002500000
19 Correct 5 ms 256 KB used 64 vertices, largest error was 0.00000004000000
20 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002500000
21 Correct 5 ms 384 KB used 288 vertices, largest error was 0.00000002500000
22 Correct 6 ms 384 KB used 764 vertices, largest error was 0.00000002500000
23 Correct 6 ms 384 KB used 680 vertices, largest error was 0.00000002500000
24 Correct 5 ms 384 KB used 568 vertices, largest error was 0.00000002500000
25 Correct 5 ms 384 KB used 260 vertices, largest error was 0.00000002400000
26 Correct 5 ms 384 KB used 316 vertices, largest error was 0.00000002400000
27 Correct 6 ms 384 KB used 596 vertices, largest error was 0.00000004000000
28 Correct 6 ms 384 KB used 932 vertices, largest error was 0.00000002500000
29 Correct 5 ms 384 KB used 344 vertices, largest error was 0.00000002500000
30 Correct 9 ms 512 KB used 2304 vertices, largest error was 0.00000004000000
31 Execution timed out 1100 ms 79188 KB Time limit exceeded
32 Halted 0 ms 0 KB -