QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56792#3873. TowersWilson_LeeCompile Error//C++2.8kb2022-10-21 16:17:202022-10-21 16:18:23

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-21 16:18:23]
  • Judged
  • [2022-10-21 16:17:20]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

typedef pair<int,int> pa;
const int MAXN=1e6+5;
struct node
{
    int x,y;
}p[MAXN];
vector<pa>X[MAXN],Y[MAXN];
int numx[MAXN],numy[MAXN],ans[MAXN];
int main()
{
    //freopen("tower.in","r",stdin);
    //freopen("tower.out","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i) scanf("%d %d",&p[i].x,&p[i].y),numx[i]=p[i].x,numy[i]=p[i].y;
    sort(numx+1,numx+n+1),sort(numy+1,numy+n+1);
    int lenx=unique(numx+1,numx+n+1)-numx-1,leny=unique(numy+1,numy+n+1)-numy-1;
    for(int i=1;i<=n;++i)
    {
        p[i].x=lower_bound(numx+1,numx+lenx+1,p[i].x)-numx;
        p[i].y=lower_bound(numy+1,numy+leny+1,p[i].y)-numy;
        printf("%d %d\n",p[i].x,p[i].y);
    }
    for(int i=1;i<=n;++i) X[p[i].x].push_back({p[i].y,i});
    for(int i=1;i<=lenx;++i)
    {
        sort(X[i].begin(),X[i].end());
        int si=X[i].size();
        Y[X[i][0].first].push_back({i,X[i][0].second});
        if(si>=2) Y[X[i][si-1].first].push_back({i,X[i][si-1].second});
    }
    for(int i=1;i<=leny;++i)
    {
        //cout<<i<<endl;
        if(Y[i].size()<=2)
        {
            for(auto j:Y[i]) ans[j.second]=1;
            continue;
        }
        //cout<<i<<endl;
        sort(Y[i].begin(),Y[i].end());
        int si=Y[i].size();
        ans[Y[i][0].second]=ans[Y[i][si-1].second]=1;
        vector<pa>tmp;
        tmp.push_back(Y[i][0]),tmp.push_back(Y[i][si-1]);
        for(int j=1;j<si-1;++j)
        {
            ans[Y[i][j].second]=0;
            pa now={i,Y[i][j].second};
            int pos=upper_bound(X[Y[i][j].first].begin(),X[Y[i][j].first].end(),now)-X[Y[i][j].first].begin();
            if(pos<X[Y[i][j].first].size()-1) Y[X[Y[i][j].first][pos].first].push_back({Y[i][j].first,X[Y[i][j].first][pos].second});
            else tmp.push_back(Y[i][j]);
        }
        Y[i]=tmp;
    }
    //for(int i=1;i<=n;++i) if(ans[i]) putchar(i+'A'-1);
    //return 0;
    for(int i=leny;i>=1;--i)
    {
        //cout<<Y[i].size()<<endl;
        if(Y[i].size()<=2)
        {
            for(auto j:Y[i]) ans[j.second]=1;
            continue;
        }
        sort(Y[i].begin(),Y[i].end());
        int si=Y[i].size();
        ans[Y[i][0].second]=ans[Y[i][si-1].second]=1;
        for(int j=1;j<si-1;++j)
        {
            ans[Y[i][j].second]=0;
            pa now={i,Y[i][j].second};
            int pos=lower_bound(X[Y[i][j].first].begin(),X[Y[i][j].first].end(),now)-X[Y[i][j].first].begin()-1;
            if(pos>0) Y[X[Y[i][j].first][pos].first].push_back({Y[i][j].first,X[Y[i][j].first][pos].second});
        }
    }
    for(int i=1;i<=n;++i) printf("%d",ans[i]);
    return 0;
}
/*
8
1 3
2 3
4 4
4 3
4 1
2 4
4 2
3 3
1011111101101100
1011110101101100
*/1011111101101100

详细

answer.code:95:3: error: expected unqualified-id before numeric constant
   95 | */1011111101101100
      |   ^~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:18:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     for(int i=1;i<=n;++i) scanf("%d %d",&p[i].x,&p[i].y),numx[i]=p[i].x,numy[i]=p[i].y;
      |                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~