QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#639460 | #5426. Drain the Water Tank | Godwang | WA | 1ms | 5772kb | C++23 | 3.4kb | 2024-10-13 19:43:49 | 2024-10-13 19:43:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
const int N=1e5+10;
/////////////////////
int tt;
int n;
struct Point
{
ll x,y;
Point()
{
}
Point(ll x,ll y):x(x),y(y){}
Point operator + (Point B)
{
return Point(x+B.x,y+B.y);
}
Point operator - (Point B)
{
return Point(x-B.x,y-B.y);
}
};
typedef Point Vector;
ll Cross(Vector A,Vector B)
{
return A.x*B.y-A.y*B.x;
}
Point p[N],ch[N];
int kaishi;
set<int > se;
/////////////////////
int pre(int u)
{
if(u==0)
{
return n-1;
}
return u-1;
}
int nxt(int u)
{
if(u==n-1)
{
return 0;
}
return u+1;
}
/////////////////////
/////////////////////
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("ain.txt","r",stdin);freopen("aout.txt","w",stdout);
cin>>n;
rep(i,0,n-1)
{
cin>>p[i].x>>p[i].y;
}
kaishi=0;
while (1)
{
int qian=pre(kaishi);
if(Cross( p[kaishi]-p[qian] , p[1]-p[kaishi])!=0)
{
break;
}
kaishi=qian;
}
int dier=1;
while (1)
{
int hou=nxt(dier);
if(Cross( p[hou]-p[dier] , p[dier]-p[kaishi])!=0)
{
break;
}
dier=hou;
}
//
bool fla=1;
int a=kaishi,b=dier,c;
se.insert(a);
se.insert(b);
//
//cout<<kaishi<<" "<<dier<<endl;
// exit(0);
int temp=0;
while (1)
{
if(fla==0)
{
a=b;
}
if(fla==0&&a==kaishi)
{
break;
}
//
se.insert(a);
fla=0;
b=nxt(a);
c=nxt(b);
//
//
// cout<<a<<" "<<b<<" "<<c<<endl;
//
while (1)
{
if(Cross(p[c]-p[b],p[b]-p[a])!=0)
{
break;
}
b=nxt(b);
c=nxt(c);
}
//
//
//cout<<a<<" "<<b<<" "<<c<<endl;
}
n=se.size();
//
int cnt=0;
for(auto i:se)
{
//
//cout<<i<<endl;
ch[cnt].x=p[i].x;
ch[cnt].y=p[i].y;
cnt++;
//
// cout<<p[i].x<<" "<<p[i].y<<endl;
}
a=0;
b=1;
c=2;
fla=1;
int ans=0;
while(1)
{
if(a==0&&fla==0)
{
break;
}
//
if(p[a].y>p[b].y&&p[b].y<p[c].y)
{
if(Cross(ch[b]-ch[a],ch[c]-ch[b])>0)
{
ans++;
//
//cout<<a<<endl;
}
}
if(p[a].y>p[b].y&&p[b].y==p[c].y)
{
int d=nxt(c);
// //
// cout<<d<<endl;
if(ch[d].y>ch[c].y&&Cross(ch[c]-ch[b],ch[d]-ch[c])>0)
{
ans++;
//
// cout<<a<<endl;
}
}
a=nxt(a);
b=nxt(b);
c=nxt(c);
fla=0;
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
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: 3592kb
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: 3668kb
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: 3656kb
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: 3668kb
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: 1ms
memory: 5764kb
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: 5636kb
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: 1ms
memory: 5636kb
input:
3 0 0 100 0 0 100
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 0ms
memory: 5712kb
input:
3 200 0 100 100 0 0
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 5716kb
input:
3 50 50 100 50 100 100
output:
1
result:
ok 1 number(s): "1"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
3 3 0 0 4 0 0
output:
1
result:
ok 1 number(s): "1"
Test #13:
score: 0
Accepted
time: 1ms
memory: 5696kb
input:
3 10000 10000 -10000 10000 10000 9999
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
3 10000 10000 -10000 10000 10000 9900
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 1ms
memory: 5704kb
input:
3 10000 10000 9999 10000 10000 -10000
output:
1
result:
ok 1 number(s): "1"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
3 0 0 200 0 100 173
output:
1
result:
ok 1 number(s): "1"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
3 0 0 200 0 100 1
output:
1
result:
ok 1 number(s): "1"
Test #18:
score: 0
Accepted
time: 1ms
memory: 5696kb
input:
3 -10000 -10000 10000 9999 9999 10000
output:
1
result:
ok 1 number(s): "1"
Test #19:
score: 0
Accepted
time: 0ms
memory: 5624kb
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: 5760kb
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: 5584kb
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: 3660kb
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: 3676kb
input:
4 0 0 100 0 100 50 0 50
output:
1
result:
ok 1 number(s): "1"
Test #24:
score: 0
Accepted
time: 1ms
memory: 5700kb
input:
4 0 0 50 0 50 100 0 100
output:
1
result:
ok 1 number(s): "1"
Test #25:
score: 0
Accepted
time: 1ms
memory: 5704kb
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: 3580kb
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: 3588kb
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: 3536kb
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: 3720kb
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: 3664kb
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: 3588kb
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: 3716kb
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: 0
Accepted
time: 0ms
memory: 5764kb
input:
10 1000 0 1100 0 1200 100 1220 200 1200 110 1100 10 1000 10 900 110 880 200 900 100
output:
1
result:
ok 1 number(s): "1"
Test #34:
score: 0
Accepted
time: 1ms
memory: 5692kb
input:
16 0 0 60 0 60 70 0 70 0 20 40 20 40 50 20 50 20 40 30 40 30 30 10 30 10 60 50 60 50 10 0 10
output:
2
result:
ok 1 number(s): "2"
Test #35:
score: 0
Accepted
time: 1ms
memory: 5772kb
input:
8 0 1 100 0 5 5 200 5 105 0 205 1 205 10 0 10
output:
2
result:
ok 1 number(s): "2"
Test #36:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
8 0 1 50 0 5 5 200 5 150 0 205 1 205 10 0 10
output:
2
result:
ok 1 number(s): "2"
Test #37:
score: 0
Accepted
time: 1ms
memory: 5768kb
input:
9 99 100 100 100 99 99 301 99 300 100 301 100 201 274 200 273 199 274
output:
1
result:
ok 1 number(s): "1"
Test #38:
score: -100
Wrong Answer
time: 0ms
memory: 3536kb
input:
15 0 0 10 0 20 0 30 0 40 0 50 0 40 10 30 20 20 30 10 40 0 50 0 40 0 30 0 20 0 10
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'