QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#708433 | #5426. Drain the Water Tank | Rightt | WA | 0ms | 3824kb | C++14 | 2.5kb | 2024-11-03 22:14:17 | 2024-11-03 22:14:25 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
struct poi{
ll x,y;
poi(){
x=0,y=0;
}
poi(ll xx,ll yy){
x=xx,y=yy;
}
};
poi operator-(poi a,poi b){return poi(a.x-b.x,a.y-b.y);};
ll cro(poi a,poi b){return a.x*b.y-b.x*a.y;}
//ToLeft测试,判断p是否在ab左边(逆时针),1左,-1右,0在线上
int toleft(poi a,poi b,poi p){
ll ans=cro((b-a) , (p-b));
if(ans==0)return 0;
if(ans>0)return 1;
return -1;
}
long long get(ll x1, ll y1, ll x2, ll y2){
return x1 * y2 - x2 * y1;
}
void solve(){
int n;
cin>>n;
ll ans=0;
vector<poi> p(5*n+5);
for(int i=0;i<n;i++){
cin>>p[i].x>>p[i].y;
p[i+3*n]=p[i+4*n]=p[i+2*n]=p[i+n]=p[i];
}
//p.push_back(p[0]);
set<pair<int, int>> se;
for(int i=n*2;i<n*3;i++){
int j=i,k=i;
while(p[k-1].y==p[k].y)k--;
while(p[j+1].y==p[j].y)j++;
// if (p[i].x == 100 && p[i].y == 0){
// cout << p[i].x << ' ' << p[i].y << '\n';
// cout << p[k-1].x << ' ' << p[k-1].y << '\n';
// cout << p[j+1].x << ' ' << p[j+1].y << '\n';
// cout << toleft(p[k-1],p[j+1],p[i]) << '\n';
// }
if(j==k&&toleft(p[k-1],p[j+1],p[i])==-1&&p[j+1].y>p[i].y&&p[k-1].y>p[i].y){
//out << p[i].x << ' ' << p[i].y << '\n';
// cout << p[k-1].x << ' ' << p[k-1].y << '\n';
// cout << p[j+1].x << ' ' << p[j+1].y << '\n';
// cout << '\n';
ans++;
}
// if (se.count({p[i].x, p[i].y})) ans --;
if (j != k && i == k &&p[j+1].y>p[i].y&&p[k-1].y>p[i].y){
ans ++ ;
}
//if (k-j-1!=1 && p[i].x>)
//cout<<i-n<<' '<<j-n<<' '<<k-n<<' '<<p[j+1].y<<' '<<p[k-1].y<<' '<<p[i].y<<endl;
//i=j;
// while (p[i].y == p[jj].y) jj ++;
// int pre = i - 1;
// if (p[i].y < p[pre].y && p[i].y < p[jj].y){
// if (p[i].y != p[i + 1].y){
// //不在水平线
// ans += get(p[i].x-p[pre].x, p[i].y-p[pre].y, p[jj].x-p[i].x, p[jj].y-p[i].y) > 0;
// }else{
// //水平线
// if (p[i+1].x > p[i].x) ans ++;
// }
// }
}
cout<<ans;
}
signed main(){
IOS;
int t = 1;
// cin >> t;
while (t -- ){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3508kb
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: 3524kb
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: 3524kb
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: 3552kb
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: 3552kb
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: 3536kb
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: 3520kb
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: 3548kb
input:
3 0 0 100 0 0 100
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
3 200 0 100 100 0 0
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3604kb
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: 0
Accepted
time: 0ms
memory: 3524kb
input:
3 10000 10000 -10000 10000 10000 9999
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
3 10000 10000 -10000 10000 10000 9900
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
3 10000 10000 9999 10000 10000 -10000
output:
1
result:
ok 1 number(s): "1"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
3 0 0 200 0 100 173
output:
1
result:
ok 1 number(s): "1"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
3 0 0 200 0 100 1
output:
1
result:
ok 1 number(s): "1"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
3 -10000 -10000 10000 9999 9999 10000
output:
1
result:
ok 1 number(s): "1"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3592kb
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: 3588kb
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: 3476kb
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: 3548kb
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: 3544kb
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: 3808kb
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: 3532kb
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: 3780kb
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: 3476kb
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: 3820kb
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: 3592kb
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: 3480kb
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: 3544kb
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: 3824kb
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: -100
Wrong Answer
time: 0ms
memory: 3780kb
input:
10 1000 0 1100 0 1200 100 1220 200 1200 110 1100 10 1000 10 900 110 880 200 900 100
output:
2
result:
wrong answer 1st numbers differ - expected: '1', found: '2'