QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#639402#5426. Drain the Water TankGodwangCompile Error//C++233.0kb2024-10-13 19:22:202024-10-13 19:22:21

Judging History

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

  • [2024-10-13 19:22:21]
  • 评测
  • [2024-10-13 19:22:20]
  • 提交

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

    int now=kaishi;
    bool fla=1;
    int a=kaishi,b=dier,c;
    se.insert(a);
    se.insert(b);

    



       //
    //cout<<kaishi<<" "<<dier<<endl;
   // exit(0);

    while (1)
    {
        
        if(fla==0)
        {
            a=b;
            b=c;
        }
        if(fla==0&&a==kaishi)
        {
            break;
        }
        se.insert(a);
        se.insert(b);
        
        fla=0;
        c=nxt(b);
        //
        
        while (1)
        {
            if(Cross(p[c]-p[b],p[b]-p[a])!=0)
            {
                break;
            }
            c=nxt(c);
        }
        se.insert(c);
    }
    
 

    n=se.size();
    //
   // cout<<n<<endl;
    int cnt=0;
    for(auto i:se)
    {
        ch[cnt].x=p[i].x;
        ch[cnt].y=p[i].y;
        cnt++;
    }

    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++;
            }
        }
        if(p[a].y>p[b].y&&p[b].y==p[c].y)4
        {
            int d=nxt(c);
           // //
           // cout<<d<<endl;
            if(Cross(ch[c]-ch[b],ch[d]-ch[c])>0)
            {
                ans++;
            }
        }


        a=nxt(a);
        b=nxt(b);
        c=nxt(c);
        fla=0;
    }


    cout<<ans;

    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:191:43: error: expected ‘;’ before ‘{’ token
  191 |         if(p[a].y>p[b].y&&p[b].y==p[c].y)4
      |                                           ^
      |                                           ;
  192 |         {
      |         ~