QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#368215#2838. 2D Geometryhshshs#WA 0ms3808kbC++141.1kb2024-03-26 22:05:202024-03-26 22:05:20

Judging History

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

  • [2024-03-26 22:05:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-03-26 22:05:20]
  • 提交

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);
	}
	if(n<3){
		cout << n << '\n';
	} 
	
	int tmp = 0;
	for (int kase = 0; kase < 60; kase++) {
		auto get = [&]() {
			return rand() % n + 1; 
		};
		int u = get();
		int v = get();
		if(u==v)continue;
		
		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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3480kb

input:

3
0 0
0 1
0 2
3
0 0
0 1
1 0
6
0 0
0 1
0 2
0 3
1 1
1 2

output:

3
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3808kb

input:

1
0 0
2
0 0
1 1
3
0 0
0 1
0 2
3
0 0
0 1
1 0
4
3 0
0 2
3 3
3 1
4
2 3
1 1
0 3
0 2
4
0 0
0 3
0 2
0 1
5
8 6
9 2
2 3
7 4
1 5
5
2 2
4 2
6 2
7 2
0 4
5
3 7
5 4
4 4
9 4
9 9
5
5 4
5 9
5 5
4 3
1 0
5
3 2
1 2
7 2
6 2
5 2
6
7 2
7 9
0 3
8 8
4 4
3 8
6
2 8
2 5
3 5
3 8
2 0
0 2
6
2 3
8 4
2 9
2 2
2 6
4 9
6
2 1
7 6
6 5
...

output:

1
1
2
2
3
0
1
1
4
2
2
2
2
5
0
0
0
0
0
0
0
3
0
6

result:

wrong answer 2nd lines differ - expected: '2', found: '1'