QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#708378#5426. Drain the Water TankRighttCompile Error//C++142.7kb2024-11-03 21:53:102024-11-03 21:53:14

Judging History

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

  • [2024-11-03 21:53:14]
  • 评测
  • [2024-11-03 21:53:10]
  • 提交

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';
        // }
        int op = 0;
        if(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++;
        op = 1;
        }
        // if (se.count({p[i].x, p[i].y})) ans --;
        if (j != k op == 1){
            //cout << p[i].x << ' ' << p[i].y << '\n';
            if (se.count({p[i].x, p[i].y})) ans --;
            else
                while (k <= j) se.insert({p[k].x, p[k++].y});
        }
        //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;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:62:19: error: expected ‘)’ before ‘op’
   62 |         if (j != k op == 1){
      |            ~      ^~~
      |                   )