QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692786 | #5426. Drain the Water Tank | Yuanyin26 | WA | 0ms | 3836kb | C++20 | 1.3kb | 2024-10-31 15:02:34 | 2024-10-31 15:02:35 |
Judging History
answer
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<cmath>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<queue>
#include<stack>
#include<functional>
#include<deque>
#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e18
using namespace std;
const int N = 2e5 + 7;
const int M = 1e6 + 7;
struct node
{
int x;
int y;
};
void solve()
{
int n;
cin >> n;
vector<node>a(2*n + 1);
bool fl = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i+n].x >> a[i+n].y;
a[i].x = a[i + n].x;
a[i].y = a[i + n].y;
if (a[i].y != a[i - 1 ? 1 : i - 1].y)fl = 1;
}
if (!fl)
{
cout << 0 << endl;
return;
}
int cnt = 0;
vector<bool>vi(n + 1,0);
for (int i = n + 1; i < 2 *n; i++)
{
if (vi[i %n])continue;
int l, r;
l = r = i;
while (a[l].y == a[i].y)
{
l--;
}
while (a[r].y == a[i].y)
{
vi[r % n] = 1;
r = (r) % (2 * n) + 1;
}
if (a[r].x < a[i].x && a[i].x < a[l].x);
else if (a[l].y > a[i].y && a[r].y > a[i].y)
{
cnt++;
vi[i % n] = 1;
}
}
cout << cnt << endl;
}
signed main() {
IOS;
int t = 1; //cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
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: 3648kb
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: 3548kb
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: 3836kb
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: 3832kb
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: 3832kb
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: 3800kb
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: 3836kb
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: 3544kb
input:
3 0 0 100 0 0 100
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 200 0 100 100 0 0
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
3 50 50 100 50 100 100
output:
1
result:
ok 1 number(s): "1"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
3 3 0 0 4 0 0
output:
1
result:
ok 1 number(s): "1"
Test #13:
score: -100
Wrong Answer
time: 0ms
memory: 3540kb
input:
3 10000 10000 -10000 10000 10000 9999
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'