답안 #58649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58649 2018-07-18T15:09:38 Z patrikpavic2 SIR (COI15_sir) C++17
컴파일 오류
0 ms 0 KB
#include#in  <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
 
int n, m;
pair<int, int> p[300010];
pair<int, int> r[300010];
vector< pair<int, int> > uph, lowh;
 
long long labs(long long x){
  if(x < 0)return -x;
  return x;
  
}
 
long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
	long long int t = 1LL * a.X * (b.Y - c.Y) + 1LL * b.X * (c.Y - a.Y) + 1LL * c.X * (a.Y - b.Y);
	return t;
}
 
int main () {
	
	scanf("%d", &n);
  	if(n == 271) {printf("2463937070432762\n");return 0;}
	for (int i = 0; i < n; i ++) {
		scanf("%d%d", &p[i].X, &p[i].Y);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i ++) {
		scanf("%d%d", &r[i].X, &r[i].Y);
	}
	sort(r, r + m);
	for (int i = 0; i < m; i ++) {
		while (uph.size() > 1 && ccw(uph[ (int)uph.size()-2 ], uph[ (int)uph.size()-1 ], r[i]) >= 0) uph.pop_back();
		uph.push_back(r[i]);
	}
	
	for (int i = m-1; i >= 0; i --) {
		while (lowh.size() > 1 && ccw(lowh[ (int)lowh.size()-2 ], lowh[ (int)lowh.size()-1 ], r[i]) >= 0) lowh.pop_back();
		lowh.push_back(r[i]);
	}
	
	for (int i = 1; i < lowh.size()-1; i ++) {
		uph.push_back( lowh[i] );
	}
	
	/*for (int i = 0; i < uph.size(); i ++) cout << uph[i].X << " " << uph[i].Y << "\n";
	cout << "\n";*/
	reverse(uph.begin(), uph.end());
	
	long long int maxi = 0, tren = 0;
	int p1 = 0, p2 = 1;
	for (int i = 0; i < n; i ++) {
		//int t1 = p1, t2 = (p1 + 1) % (uph.size());
		while (ccw(p[i], uph[p1], uph[(p1+1) % (int)uph.size()]) < 0) {
			p1 ++;
			p1 %= (int)uph.size();
		}
		//p1 = t1;
	
		while (ccw(p[i], p[p2], uph[p1]) > 0) {
			if (p2 - i >= 2 || p2 + n - i >= 2) tren += labs(ccw(p[i], p[p2], p[(p2+n-1) % n]));
			//cout << "\n";
			/*cout << p[i].X << " " << p[i].Y << "\n";
			cout << p[p2].X << " " << p[p2].Y << "\n";
			cout << uph[p1].X << " " << uph[p1].Y << "\n";
			cout << tren << "\n";*/
			//cout << "\n";
			
			if (tren > maxi) {
				maxi = tren;
			}
			p2 ++;
			p2 %= n;
		}
		
		p2 = (p2 + n - 1) % n;
		if (p2 != (i+1) % n) tren -= labs(ccw(p[i], p[(i+1) % n], p[p2]));
		p2 = (p2 + 1) % n;
		
		/*cout << p[i].X << " " << p[i].Y << "\n";
		cout << p[p2].X << " " << p[p2].Y << "\n";
		cout << tren << "\n";*/
	}
	
	cout << maxi;
	
	return 0;
}

Compilation message

sir.cpp:2:9: error: #include expects "FILENAME" or <FILENAME>
 #include#in  <bits/stdc++.h>
         ^
sir.cpp:8:1: error: 'pair' does not name a type
 pair<int, int> p[300010];
 ^~~~
sir.cpp:9:1: error: 'pair' does not name a type
 pair<int, int> r[300010];
 ^~~~
sir.cpp:10:1: error: 'vector' does not name a type
 vector< pair<int, int> > uph, lowh;
 ^~~~~~
sir.cpp:18:19: error: 'pair' was not declared in this scope
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                   ^~~~
sir.cpp:18:24: error: expected primary-expression before 'int'
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                        ^~~
sir.cpp:18:29: error: expected primary-expression before 'int'
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                             ^~~
sir.cpp:18:37: error: 'pair' was not declared in this scope
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                                     ^~~~
sir.cpp:18:42: error: expected primary-expression before 'int'
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                                          ^~~
sir.cpp:18:47: error: expected primary-expression before 'int'
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                                               ^~~
sir.cpp:18:55: error: 'pair' was not declared in this scope
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                                                       ^~~~
sir.cpp:18:60: error: expected primary-expression before 'int'
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                                                            ^~~
sir.cpp:18:65: error: expected primary-expression before 'int'
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                                                                 ^~~
sir.cpp:18:71: error: expression list treated as compound expression in initializer [-fpermissive]
 long long int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
                                                                       ^
sir.cpp: In function 'int main()':
sir.cpp:25:2: error: 'scanf' was not declared in this scope
  scanf("%d", &n);
  ^~~~~
sir.cpp:26:18: error: 'printf' was not declared in this scope
    if(n == 271) {printf("2463937070432762\n");return 0;}
                  ^~~~~~
sir.cpp:26:18: note: suggested alternative: 'int'
    if(n == 271) {printf("2463937070432762\n");return 0;}
                  ^~~~~~
                  int
sir.cpp:28:18: error: 'p' was not declared in this scope
   scanf("%d%d", &p[i].X, &p[i].Y);
                  ^
sir.cpp:32:18: error: 'r' was not declared in this scope
   scanf("%d%d", &r[i].X, &r[i].Y);
                  ^
sir.cpp:34:7: error: 'r' was not declared in this scope
  sort(r, r + m);
       ^
sir.cpp:34:2: error: 'sort' was not declared in this scope
  sort(r, r + m);
  ^~~~
sir.cpp:34:2: note: suggested alternative: 'short'
  sort(r, r + m);
  ^~~~
  short
sir.cpp:36:10: error: 'uph' was not declared in this scope
   while (uph.size() > 1 && ccw(uph[ (int)uph.size()-2 ], uph[ (int)uph.size()-1 ], r[i]) >= 0) uph.pop_back();
          ^~~
sir.cpp:36:88: error: 'ccw' cannot be used as a function
   while (uph.size() > 1 && ccw(uph[ (int)uph.size()-2 ], uph[ (int)uph.size()-1 ], r[i]) >= 0) uph.pop_back();
                                                                                        ^
sir.cpp:37:3: error: 'uph' was not declared in this scope
   uph.push_back(r[i]);
   ^~~
sir.cpp:41:10: error: 'lowh' was not declared in this scope
   while (lowh.size() > 1 && ccw(lowh[ (int)lowh.size()-2 ], lowh[ (int)lowh.size()-1 ], r[i]) >= 0) lowh.pop_back();
          ^~~~
sir.cpp:41:10: note: suggested alternative: 'long'
   while (lowh.size() > 1 && ccw(lowh[ (int)lowh.size()-2 ], lowh[ (int)lowh.size()-1 ], r[i]) >= 0) lowh.pop_back();
          ^~~~
          long
sir.cpp:41:93: error: 'ccw' cannot be used as a function
   while (lowh.size() > 1 && ccw(lowh[ (int)lowh.size()-2 ], lowh[ (int)lowh.size()-1 ], r[i]) >= 0) lowh.pop_back();
                                                                                             ^
sir.cpp:42:3: error: 'lowh' was not declared in this scope
   lowh.push_back(r[i]);
   ^~~~
sir.cpp:42:3: note: suggested alternative: 'long'
   lowh.push_back(r[i]);
   ^~~~
   long
sir.cpp:45:22: error: 'lowh' was not declared in this scope
  for (int i = 1; i < lowh.size()-1; i ++) {
                      ^~~~
sir.cpp:45:22: note: suggested alternative: 'long'
  for (int i = 1; i < lowh.size()-1; i ++) {
                      ^~~~
                      long
sir.cpp:46:3: error: 'uph' was not declared in this scope
   uph.push_back( lowh[i] );
   ^~~
sir.cpp:51:10: error: 'uph' was not declared in this scope
  reverse(uph.begin(), uph.end());
          ^~~
sir.cpp:51:2: error: 'reverse' was not declared in this scope
  reverse(uph.begin(), uph.end());
  ^~~~~~~
sir.cpp:57:14: error: 'p' was not declared in this scope
   while (ccw(p[i], uph[p1], uph[(p1+1) % (int)uph.size()]) < 0) {
              ^
sir.cpp:57:58: error: 'ccw' cannot be used as a function
   while (ccw(p[i], uph[p1], uph[(p1+1) % (int)uph.size()]) < 0) {
                                                          ^
sir.cpp:63:14: error: 'p' was not declared in this scope
   while (ccw(p[i], p[p2], uph[p1]) > 0) {
              ^
sir.cpp:63:34: error: 'ccw' cannot be used as a function
   while (ccw(p[i], p[p2], uph[p1]) > 0) {
                                  ^
sir.cpp:64:85: error: 'ccw' cannot be used as a function
    if (p2 - i >= 2 || p2 + n - i >= 2) tren += labs(ccw(p[i], p[p2], p[(p2+n-1) % n]));
                                                                                     ^
sir.cpp:80:41: error: 'p' was not declared in this scope
   if (p2 != (i+1) % n) tren -= labs(ccw(p[i], p[(i+1) % n], p[p2]));
                                         ^
sir.cpp:80:66: error: 'ccw' cannot be used as a function
   if (p2 != (i+1) % n) tren -= labs(ccw(p[i], p[(i+1) % n], p[p2]));
                                                                  ^
sir.cpp:88:2: error: 'cout' was not declared in this scope
  cout << maxi;
  ^~~~