QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#708266#5426. Drain the Water TankRighttWA 0ms3820kbC++141.3kb2024-11-03 20:55:042024-11-03 20:55:11

Judging History

你现在查看的是最新测评结果

  • [2024-11-03 20:55:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-11-03 20:55:04]
  • 提交

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;
}

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]);
    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(toleft(p[k-1],p[j+1],p[i])==-1&&toleft(p[k-1],p[j+1],p[i])==-1&&p[j+1].y>=p[i].y&&p[k-1].y>=p[i].y)
        ans++;
        //cout<<i-n<<' '<<j-n<<' '<<k-n<<' '<<p[j+1].y<<' '<<p[k-1].y<<' '<<p[i].y<<endl;
        i=j;
    }
    cout<<ans;
}

signed main(){
    IOS;
    int t = 1;
//        cin >> t;
    while (t -- ){
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

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: 3820kb

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: 3588kb

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: 3744kb

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: 3592kb

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: 3544kb

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: 3476kb

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: 3528kb

input:

5
0 0
1 2
1 5
0 2
0 1

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3516kb

input:

3
0 0
100 0
0 100

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'