QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#639333#5426. Drain the Water TanknnkWA 0ms3860kbC++201.8kb2024-10-13 19:02:132024-10-13 19:02:13

Judging History

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

  • [2024-10-13 19:02:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3860kb
  • [2024-10-13 19:02:13]
  • 提交

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;
long long cross(long long x1, long long y1, long long x2, long long y2) {
	return x1 * y2 - x2 * y1;
}
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 and x3>=x1) { ++ans; }
		else if (y0>y1 and y1< y2 and cross(x1 - x0, y1 - y0, x2 - x1, y2-y1) > 0) 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: 3780kb

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: 3556kb

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: 3612kb

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: 3624kb

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: 3652kb

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: 3776kb

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: 3552kb

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: 3616kb

input:

3
0 0
100 0
0 100

output:

1

result:

ok 1 number(s): "1"

Test #10:

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

input:

3
200 0
100 100
0 0

output:

1

result:

ok 1 number(s): "1"

Test #11:

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

input:

3
50 50
100 50
100 100

output:

1

result:

ok 1 number(s): "1"

Test #12:

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

input:

3
3 0
0 4
0 0

output:

1

result:

ok 1 number(s): "1"

Test #13:

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

input:

3
10000 10000
-10000 10000
10000 9999

output:

1

result:

ok 1 number(s): "1"

Test #14:

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

input:

3
10000 10000
-10000 10000
10000 9900

output:

1

result:

ok 1 number(s): "1"

Test #15:

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

input:

3
10000 10000
9999 10000
10000 -10000

output:

1

result:

ok 1 number(s): "1"

Test #16:

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

input:

3
0 0
200 0
100 173

output:

1

result:

ok 1 number(s): "1"

Test #17:

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

input:

3
0 0
200 0
100 1

output:

1

result:

ok 1 number(s): "1"

Test #18:

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

input:

3
-10000 -10000
10000 9999
9999 10000

output:

1

result:

ok 1 number(s): "1"

Test #19:

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

input:

4
10 10
20 10
20 20
10 20

output:

1

result:

ok 1 number(s): "1"

Test #20:

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

input:

4
-10000 -10000
10000 -10000
10000 10000
-10000 10000

output:

1

result:

ok 1 number(s): "1"

Test #21:

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

input:

4
100 0
200 100
100 200
0 100

output:

1

result:

ok 1 number(s): "1"

Test #22:

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

input:

4
0 1
100 0
101 100
1 101

output:

1

result:

ok 1 number(s): "1"

Test #23:

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

input:

4
0 0
100 0
100 50
0 50

output:

1

result:

ok 1 number(s): "1"

Test #24:

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

input:

4
0 0
50 0
50 100
0 100

output:

1

result:

ok 1 number(s): "1"

Test #25:

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

input:

4
0 10
10 0
100 90
90 100

output:

1

result:

ok 1 number(s): "1"

Test #26:

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

input:

8
0 100
100 0
250 0
350 100
350 250
250 350
100 350
0 250

output:

1

result:

ok 1 number(s): "1"

Test #27:

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

input:

6
0 50
10 0
70 0
80 10
70 50
50 80

output:

1

result:

ok 1 number(s): "1"

Test #28:

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

input:

4
0 100
0 0
100 0
20 20

output:

1

result:

ok 1 number(s): "1"

Test #29:

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

input:

4
0 100
55 55
100 0
100 100

output:

1

result:

ok 1 number(s): "1"

Test #30:

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

input:

8
0 0
100 0
100 20
40 20
40 40
100 40
100 60
0 60

output:

1

result:

ok 1 number(s): "1"

Test #31:

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

input:

12
0 0
90 0
90 30
40 30
40 40
90 40
90 50
0 50
0 20
50 20
50 10
0 10

output:

1

result:

ok 1 number(s): "1"

Test #32:

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

input:

12
0 0
100 0
100 100
10 100
10 110
200 110
200 60
101 60
101 40
210 40
210 120
0 120

output:

2

result:

ok 1 number(s): "2"

Test #33:

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

input:

10
1000 0
1100 0
1200 100
1220 200
1200 110
1100 10
1000 10
900 110
880 200
900 100

output:

1

result:

ok 1 number(s): "1"

Test #34:

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

input:

16
0 0
60 0
60 70
0 70
0 20
40 20
40 50
20 50
20 40
30 40
30 30
10 30
10 60
50 60
50 10
0 10

output:

2

result:

ok 1 number(s): "2"

Test #35:

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

input:

8
0 1
100 0
5 5
200 5
105 0
205 1
205 10
0 10

output:

2

result:

ok 1 number(s): "2"

Test #36:

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

input:

8
0 1
50 0
5 5
200 5
150 0
205 1
205 10
0 10

output:

2

result:

ok 1 number(s): "2"

Test #37:

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

input:

9
99 100
100 100
99 99
301 99
300 100
301 100
201 274
200 273
199 274

output:

1

result:

ok 1 number(s): "1"

Test #38:

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

input:

15
0 0
10 0
20 0
30 0
40 0
50 0
40 10
30 20
20 30
10 40
0 50
0 40
0 30
0 20
0 10

output:

1

result:

ok 1 number(s): "1"

Test #39:

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

input:

11
0 0
100 0
90 5
80 10
70 15
60 20
50 25
40 20
30 15
20 10
10 5

output:

1

result:

ok 1 number(s): "1"

Test #40:

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

input:

8
0 0
20 30
0 60
0 50
0 40
0 30
0 20
0 10

output:

1

result:

ok 1 number(s): "1"

Test #41:

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

input:

18
0 0
20 0
40 0
60 0
80 0
100 0
120 0
120 30
120 60
120 90
120 120
80 120
40 120
0 120
0 96
0 72
0 48
0 24

output:

0

result:

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