QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#639151#5426. Drain the Water TanknnkWA 0ms3856kbC++201.7kb2024-10-13 18:06:042024-10-13 18:06:05

Judging History

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

  • [2024-10-13 18:06:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3856kb
  • [2024-10-13 18:06:04]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<math.h>
#include<map>
#include<bitset>
#include<numeric>
#include <cstring>
#include<array>
#include <string>  
#include<unordered_set>
using namespace std;
#define int long long
#define endl "\n"
#define mod 1000000007ll
#define IOS  ios::sync_with_stdio(false),cin.tie(nullptr)
#define syy return
const double pi = acos(-1.0);
using ll = long long;
using pii = pair<int, int>;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vint>;
using vpo = vector<pii>;
using tup = tuple<int, int, int>;
using vbl = vector<bool>;
constexpr int N = 500005, M = 2000006;//开足够的空间 注意无向图的双向边边数*2
constexpr ll inf = 3e18+5000;

void slove() {
	int n; cin >> n;
	vpo a(n);
	vpo b;
	for (auto& [x, y] : a)cin >> x >> y;
	for (int i = 0; i < n; i++) {
		int j = (i - 1 + n) % n;
		int k = (i + 1) % n;
		auto [x1, y1] = a[i];
		auto [x0, y0] = a[j];
		auto [x2, y2] = a[k];
		
		if ((x0 == x1 and x1 == x2) or (y1 == y0 and y1 == y2))
		{
			i++;
			continue;
		}
		b.push_back(a[i]);
	}
	n = b.size();
	//cout << n << endl;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int j = (i - 1 + n) % n;
		int k = (i + 1) % n;
		int z = (i + 2) % n;
		auto [x0, y0] = b[j];
		auto [x1, y1] = b[i];
		auto [x2, y2] = b[k];
		auto [x3, y3] = b[z];
		if ( y1 == y2  and y1<y0 and y1<y3)++ans;
		else if ( y0 > y1 and x1>=x0 and y1 <= y2) {
			++ans;
		}
		
	}
	cout << ans << endl;
}


signed main()
{
	IOS;
	int T = 1;
	//cin >> T;
	while (T--) {
		slove();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

8
4 4
0 4
0 2
1 2
2 2
2 0
3 0
4 0

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

7
1 0
3 4
0 3
1 2
2 3
1 1
0 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

8
0 0
1 0
3 -1
3 0
1 1
4 1
5 0
3 4

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

5
0 0
170 0
140 30
60 30
0 70

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

5
0 0
170 0
140 30
60 30
0 100

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

5
0 0
1 2
1 5
0 2
0 1

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

3
0 0
100 0
0 100

output:

1

result:

ok 1 number(s): "1"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

3
200 0
100 100
0 0

output:

1

result:

ok 1 number(s): "1"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

3
50 50
100 50
100 100

output:

1

result:

ok 1 number(s): "1"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

3
3 0
0 4
0 0

output:

1

result:

ok 1 number(s): "1"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3
10000 10000
-10000 10000
10000 9999

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

3
10000 10000
-10000 10000
10000 9900

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

3
10000 10000
9999 10000
10000 -10000

output:

1

result:

ok 1 number(s): "1"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3
0 0
200 0
100 173

output:

1

result:

ok 1 number(s): "1"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

3
0 0
200 0
100 1

output:

1

result:

ok 1 number(s): "1"

Test #18:

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

input:

3
-10000 -10000
10000 9999
9999 10000

output:

0

result:

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