QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368152#2832. Graph Theoryhshshs#RE 0ms0kbC++201.3kb2024-03-26 21:14:102024-03-26 21:14:11

Judging History

你现在查看的是最新测评结果

  • [2024-03-26 21:14:11]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-03-26 21:14:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n ;
void solve() {
	vector<pair<int, int>> p(n + 1);
	for (int i = 1; i <= n; ++i)
	{
		int x, y;
		cin >> x >> y;
		p[i] = make_pair(x, y);
	}
	
	int tmp = 0;
	for (int kase = 0; kase < 20; kase++) {
		auto get = [&](int L, int R) {
			return (rand() << 15 | rand()) % (R-L+1) + L; 
		};
		int u = get(2, n);
		int v = get(1, u - 1);
//		cout << u << ' ' << v << '\n';
//		pair<int, int> line = [&](int u, int v) -> pair<int, int>{
//			return make_pair(p[u].first - p[v].first, p[u].second - p[v].second);
//		};
		
		auto dot = [](int x1, int y1, int x2, int y2) {
			return x1 * y2 - x2 * y1;	
		};
		
		auto online = [&](int u, int v, int w) -> bool {
			return 0 == dot(p[u].first - p[v].first, p[u].second - p[v].second, p[u].first - p[w].first, p[u].second - p[w].second) << ' ';
		};
		
		int res = 0;
		for (int i = 1; i <= n; ++i) {
			if (online(u, v, i)) res++;
		}
		
		tmp = max(tmp, res);
	}
//	cout << tmp << '\n';
	if (tmp >= 2 * (n - tmp)) {
		cout << tmp - 2 * (n - tmp) << '\n'; 
	} else {
		cout << n % 3 << '\n';
	}	
}

signed main() {
//	freopen("1.in", "r", stdin); 
	ios::sync_with_stdio(false);
    while (cin >> n) {
    	solve();
	} 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3 2
1 2
2 3
3 2
1 1
2 2
3 3
1 2
2 3
3 1

output:


result: