QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#649322 | #5426. Drain the Water Tank | ONISINO | WA | 0ms | 3600kb | C++20 | 2.1kb | 2024-10-17 22:48:15 | 2024-10-17 22:48:15 |
Judging History
answer
#include <bits/stdc++.h>
//DEBUG: https://github.com/sharkdp/dbg-macro
#ifdef LOCAL
#include "../dbg-macro-0.5.1/dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
#define endl '\n'
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef long double llf;
const ll MAXN=2e5+10,MOD=998244353,INF=1e9;
ll qpow(ll base,ll exp){ll ans=1;while(exp){if(exp&1)(ans*=base)%=MOD;(base*=base)%=MOD;exp>>=1;}return ans;}
template<class T>ll max_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r+1)/2;if(cmp^!check(m))l=m;else r=m-1;}return l;}
template<class T>ll min_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r)/2;if(cmp^!check(m))r=m;else l=m+1;}return r;}
ll exgcd(ll a,ll b,ll &x,ll &y){ll tmp;return b==0?(x=1,y=0,a):(tmp=exgcd(b,a%b,y,x),y-=(a/b)*x,tmp);}
ll highbit(ll x){for(ll i=1;i<(ll)sizeof(ll)*4;i<<=1)x|=x>>i;return x-(x>>1);}
ll lowbit(ll x){return x&(-x);}
//--------Global declared area--------
ll cross(pair<ll,ll> x,pair<ll,ll> y,pair<ll,ll> z){
//x1*y2-x2*y1
return (x.first-y.first)*(z.second-y.second)-(z.first-y.first)*(x.second-y.second);
}
void p(pair<ll,ll> x){
cout<<x.first<<','<<x.second<<endl;
}
//--------Global declared end --------
void solve(int test_num){
int n,ans=1;
cin>>n;
vector<pair<ll,ll>> a(2*n);
for(int i=0;i<n;i++){
cin>>a[i].first>>a[i].second;
a[i+n]=a[i];
}
int l=0,r=0;
while(a[l].second==a[(l-1+n)%n].second){
l=(l-1+n)%n;
}
while(r<n){
while(a[r].second==a[(r+1)%n].second&&r<n){
r=r+1;
}
if(r>=n){
break;
}
ll tmp=cross(a[(l-1+n)%n],a[r],a[(r+1)%n]);
// ll tmp2=cross(a[(l-1+n)%n],a[l],a[(r+1)%n]);
if(a[(l-1+n)%n].second<a[l].second&&a[(r+1)%n].second<a[r].second&&((l==r&&tmp>0)||a[l].first<=a[r].first)){
ans++;
cout<<"l r: "<<l<<' '<<r<<endl;
p(a[l]);
p(a[r]);
}
l=r=r+1;
}
cout<<ans<<endl;
}
int main(){
//std::ios::sync_with_stdio(false);
//std::cin.tie(nullptr),std::cout.tie(nullptr);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++){
solve(i);
//cout.flush();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3600kb
input:
6 0 0 1 1 2 1 3 0 3 2 0 2
output:
l r: 1 2 1,1 2,1 2
result:
wrong output format Expected integer, but "l" found