QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692610 | #5426. Drain the Water Tank | Yuanyin26 | WA | 1ms | 3800kb | C++20 | 1.3kb | 2024-10-31 14:47:12 | 2024-10-31 14:47:12 |
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[l].x <= a[r].x && 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: 3616kb
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: 3608kb
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: 1ms
memory: 3800kb
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: -100
Wrong Answer
time: 0ms
memory: 3548kb
input:
6 0 0 2 0 1 1 4 1 5 0 3 4
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'