QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#717443#5426. Drain the Water TankXiaoYang3WA 0ms3804kbC++23981b2024-11-06 17:58:452024-11-06 17:58:51

Judging History

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

  • [2024-11-06 17:58:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-11-06 17:58:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
ll n, m, k, ans;
const int N = 4e6 + 5;
const int P = 1e9 + 7;
void solve() {
    cin >> n;
    vector<pii> ve(n + 2);
    for (int i = 0; i < n; i++) {
        cin >> ve[i].first >> ve[i].second;
    }
    for (int i = 0; i < n; i++) {
        int pre = (i + n - 1) % n;

        if (ve[pre].second <= ve[i].second) {
            continue;
        }
        int j = (i + 1) % n;
        while (j != i && ve[i].second == ve[j].second) {
            j = (j + 1) % n;
        }
        if (ve[i].second > ve[j].second) {
            continue;
        }
        if (ve[i].first < ve[j].first || ve[pre].first < ve[i].first) {
           
            ans++;
        }
    }
    cout << ans << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
    // cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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

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

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

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

input:

5
0 0
1 2
1 5
0 2
0 1

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

3
0 0
100 0
0 100

output:

0

result:

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