QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#672499#7906. Almost ConvexguodongCompile Error//C++171.8kb2024-10-24 17:05:092024-10-24 17:05:09

Judging History

This is the latest submission verdict.

  • [2024-10-24 17:05:09]
  • Judged
  • [2024-10-24 17:05:09]
  • Submitted

answer

#include <bits/stdc++.h>
#define For(i,a,b) for(int i = a; i <= b; ++i)
#define int long long 
using namespace std;
const int N = 100200;
int q[N];
struct P{
    int x,y;
}a[N];
bool cmp(P a,P b){
    if(a.x == b.x) 
        return a.y < b.y;
    return a.x < b.x;
}
signed main()
{
    int A,B,C,D,r = 0,t;
    ios::sync_with_stdio(false);
    #ifdef NICEGUODONG
        freopen("data.in","r",stdin);
        ios::sync_with_stdio(true);
    #endif
    A = C = ~0U>>1;
    B = D = -A;
    int n;
    cin >> n;
    For(i,1,n){
        cin >> a[i].x >> a[i].y;
        A = min(A,a[i].x);
        B = max(B,a[i].x);
        C = min(C,a[i].y);
        D = max(D,a[i].y);
    }
    sort(a + 1, a + n + 1,cmp);
    t = 0;
    For(i,1,n)
        if(!t || a[i].y > r)
            r = a[i].y,q[++t] =i; 
    for(int i = q[r = t] + 1; i <= n; q[++t] = i++)
        while(t > r && a[i].y >= a[q[t]].y)
            t--;
    vector<int> Mark(n + 1);
    For(i,1,t){
        Mark[q[i]] = 1;
    }
    t = 0;  
    For(i,1,n)
        if(!t || a[i].y < r)
            r = a[i].y,q[++t] =i; 
    for(int i = q[r = t] + 1,i=q[t] + 1; i <= n; q[++t] = i++)
        while(t > r && a[i].y <= a[q[t]].y)
            t--;
    int ans = 1;   For(i,1,t){
        Mark[q[i]] = 1;
    }
    for(int i = 1; i <= n; ++i){
        vector<pair<long double,int>> p;
        if(Mark[i]) continue;
        for(int j = 1; j <= n; ++j){
            if(i == j) continue;
            p.push_back(make_pair(atan2(a[j].y - a[i].y,a[j].x - a[i].x),j));
        }
        sort(p.begin(),p.end());
        if(p.size() == 0) continue;
        for(int i = 0;i < (int)p.size(); ++i)
            if(Mark[p[i].second] && Mark[p[(i + 1) % p.size()].second]){
ans++;
            }
    }
    cout << ans << '\n';
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:50:30: error: redeclaration of ‘long long int i’
   50 |     for(int i = q[r = t] + 1,i=q[t] + 1; i <= n; q[++t] = i++)
      |                              ^
answer.code:50:13: note: ‘long long int i’ previously declared here
   50 |     for(int i = q[r = t] + 1,i=q[t] + 1; i <= n; q[++t] = i++)
      |             ^