QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#678231#5426. Drain the Water TankyimgWA 0ms3828kbC++201.2kb2024-10-26 14:22:302024-10-26 14:22:30

Judging History

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

  • [2024-10-26 14:22:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3828kb
  • [2024-10-26 14:22:30]
  • 提交

answer

#include<bits/stdc++.h>
#define nxt(x) (x + 1) % n
#define lst(x) (x - 1 + n) % n
using namespace std;

void work()
{
	int n;
	cin >> n;
	deque<pair<int, int>> a;
	for(int i = 0; i < n; ++i){
		int x, y; cin >> x >> y;
		a.push_back({x, y});
	}
	while(a[0].second <= a[1].second){
		a.push_back(a.front());
		a.pop_front();
	}
	int l = 0, r = 0, ans = 0;
	auto dec = [&](int c1, int c2, int c3){
		int x1 = a[c1].first, x2 = a[c2].first, x3 = a[c3].first;
		int y1 = a[c1].second, y2 = a[c2].second, y3 = a[c3].second;
		cout << (x1 - x2)*(y3 - y2) - (x3 - x2)*(y1 - y2) << "\n";
		return (x1 - x2)*(y3 - y2) <= (x3 - x2)*(y1 - y2);
	};
	for(int i = 0; i < n; ++i)
	{
		if(a[nxt(i)].second != a[i].second){
			r = i;
			if(a[lst(l)].second > a[l].second && a[nxt(r)].second > a[r].second && dec(lst(l), r, nxt(r))){
				ans++;
			}
//			cout << " HH :  "  << l << " " << r << " " << (a[lst(l)].second > a[l].second && a[nxt(r)].second > a[r].second)  << "\n";
			l = nxt(i);
		}
	}
	cout << ans << "\n";
} 

/*
7
0 5
0 3
1 3
1 2
2 2
2 1
3 1
*/
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
		work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3828kb

input:

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

output:

-2
-2
2

result:

wrong answer 1st numbers differ - expected: '2', found: '-2'