Submission #549146

# Submission time Handle Problem Language Result Execution time Memory
549146 2022-04-15T10:09:27 Z kingfran1907 SIR (COI15_sir) C++14
12 / 100
1000 ms 3224 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n, m;
pair<int, int> niz[maxn], ss[maxn];

llint ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
	return (llint)a.X * (b.Y - c.Y) + (llint)b.X * (c.Y - a.Y) + (llint)c.X * (a.Y - b.Y);
} 

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		niz[i] = {x, y};
	}

	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ss[i] = {x, y};
	}

	llint sol = 0;
	for (int i = 0; i < n; i++) {
		llint tren = 0;
		for (int j = 1; j < n; j++) {
			int ptr = (i + j) % n;
			tren += abs(ccw(niz[i], niz[(ptr + n - 1) % n], niz[ptr]));
			bool flag = true;
			for (int k = 0; k < m; k++) {
				if (ccw(niz[i], niz[ptr], ss[k]) <= 0) flag = false;
			}

			//if (flag) printf("%d --> %d (%lld)\n", i, ptr, tren);
			if (flag) sol = max(sol, tren);
			else break;
		}
	}
	printf("%lld\n", sol);
	return 0;
}

Compilation message

sir.cpp: In function 'int main()':
sir.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sir.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d%d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~
sir.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%d", &m);
      |  ~~~~~^~~~~~~~~~
sir.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   scanf("%d%d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 328 KB Output is correct
2 Correct 18 ms 340 KB Output is correct
3 Execution timed out 1088 ms 404 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 3224 KB Time limit exceeded
2 Halted 0 ms 0 KB -