QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368129#2838. 2D Geometryhshshs#Compile Error//C++201.0kb2024-03-26 21:00:072024-03-26 21:00:07

Judging History

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

  • [2024-03-26 21:00:07]
  • 评测
  • [2024-03-26 21:00:07]
  • 提交

answer

#include<bits/stdc++.h>
#define maxn 100010
using namespace std;
int n,q,a1,a2;
string s;

void solve() {
	vector<pair<int, int>> p;
	for (int i = 0; i < n; ++i)
	{
		int x, y;
		cin >> x >> y;
		p.push_back({x, y});
	}
	
	int tmp = 0;
	for (int kase = 0; kase < 20; kase++) {
		auto get = [&](int L, int R) {
			return (rand() << 15 | rand()) % R + L; 
		};
		int u = get(2, n);
		int v = get(1, u - 1);
		pair<int,int> line = [&](int u, int v) ->  {
			return {p[u].first - p[v].fisrt, p[u].second - p[v].second};
		};
		auto online = [&](int u, int v, int w) {
			auto x = line(u, v), y = line(v, w);
			return x.first * y.second - x.second * y.first;
		};
		int res=0;
		for (int i = 1; i <= n; ++i) {
			if (online(u, v, i)) res++;
		}
		
		tmp = max(tmp, res);
	}
	if (tmp >= 2* (n - tmp)) {
		cout << tmp - 2 * (n - tmp) << '\n'; 
	} else {
		cout << n % 3 << '\n';
	}	
}

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

Details

answer.code: In function ‘void solve()’:
answer.code:23:60: error: expected type-specifier before ‘{’ token
   23 |                 pair<int,int> line = [&](int u, int v) ->  {
      |                                                            ^
answer.code: In lambda function:
answer.code:27:38: error: no match for call to ‘(std::pair<int, int>) (int&, int&)’
   27 |                         auto x = line(u, v), y = line(v, w);
      |                                  ~~~~^~~~~~
answer.code:28:42: error: ‘y’ was not declared in this scope
   28 |                         return x.first * y.second - x.second * y.first;
      |                                          ^