QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#735594 | #5426. Drain the Water Tank | NULL_SF | WA | 0ms | 3672kb | C++23 | 1.4kb | 2024-11-11 20:51:38 | 2024-11-11 20:51:39 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
pair<int,int> a[1000001];
vector<pair<int,int>> b;
signed main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i].first>>a[i].second;
}
for(int i=0;i<n;i++){
int dx1=a[i].first - a[(i+n-1)%n].first;
int dy1=a[i].second - a[(i+n-1)%n].second;
int dx2=a[(i+1)%n].first - a[i].first;
int dy2=a[(i+1)%n].second - a[i].second;
b.push_back(a[i]);
if(dx1*dy2 == dx2*dy1)
{
b.pop_back();
}
}
int ans=0;
n=(int)b.size();
for(int i=0;i<n;i++)
{
if(b[i].second < b[(i+1)%n].second && b[i].second < b[(i-1+n)%n].second)
{
int dx1=b[i].first - b[(i+n-1)%n].first;
int dy1=b[i].second - b[(i+n-1)%n].second;
int dx2=b[(i+1)%n].first - b[i].first;
int dy2=b[(i+1)%n].second - b[i].second;
if(dx1==0)
{
if(dx2*dy2>0) ans++;
}
else if(dx2==0)
{
if(dx1*dy1<0) ans++;
}
else
{
if(dx1*dy1<0)
{
if(dx2*dy2>0 || dx2*dy1>dx1*dy2) ans++;
}
else
{
if(dx2*dy2>0 && dx2*dy1>dx1*dy2) ans++;
}
}
}
}
for(int i=0;i<n;i++)
{
if(b[i].first <= b[(i+3)%n].first && b[i].second > b[(i+1)%n].second && b[(i+3)%n].second > b[(i+1)%n].second && b[(i+2)%n].second == b[(i+1)%n].second && b[(i+2)%n].first > b[(i+1)%n].first)
{
ans++;
}
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
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: 3672kb
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: 3484kb
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: 3668kb
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'