Submission #1302356

#TimeUsernameProblemLanguageResultExecution timeMemory
1302356bonr_to_debugTowers (NOI22_towers)C++20
6 / 100
301 ms68236 KiB

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
int n;
pair<int,int> a[1000005];
vector<pair<int,int>> posy[1000005];
bool va[1000005];
namespace sub1
{
void solve()
{
    int full=1<<n,best=0;
    for (int mask=0; mask<=full; mask++)
    {
        bool cch[36];
        for (int i=1; i<=n; i++)
        {
            cch[i]=false;
        }
        vector<int>pos;
        int last=0,res=0;
        for (int i=0; i<n; i++)
        {
            if ((mask>>i)&1)
            {
                pos.push_back(i+1);
                cch[i+1]=true;
            }
        }
        bool ok=false;
        for (int i=1; i<=n; i++)
        {
            if (!cch[i])
            {
                bool ok1=false,ok2=false,ok3=false,ok4=false;
                for (int j=0;j<(int)pos.size(); j++)
                {
                    if (a[pos[j]].fi==a[i].fi && a[pos[j]].se<a[i].se) ok1=true;
                    if (a[pos[j]].fi==a[i].fi && a[pos[j]].se>a[i].se) ok2=true;
                    if (a[pos[j]].se==a[i].se && a[pos[j]].fi>a[i].fi) ok3=true;
                    if (a[pos[j]].se==a[i].se && a[pos[j]].fi<a[i].fi) ok4=true;
                }
                if ((ok1 && ok2) || (ok3 && ok4))
                {
                    ok=true;
                }
                else
                {
                    ok=false;
                    break;
                }
            }
        }
        if (ok) {
            for (int i=0; i<n; i++) cout<<((mask>>i)&1);
            return;
        }
    }
}
}
signed main()
{
    //freopen("SLAMP.INP","r",stdin);
    //freopen("SLAMP.OUT","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>n;
    int maxy=0;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i].first>>a[i].second;
        maxy=max(maxy,a[i].second);
        posy[a[i].se].push_back({a[i].fi,i});
    }

    for (int i=1;i<=maxy;i++)
    {
        int x=posy[i].size();
        if (x==0) continue;
        int b1=0,b2=LLONG_MAX,c1,c2;
        for (pair<int,int>xx : posy[i])
        {
            if (xx.fi>b1)
            {
                b1=xx.fi;
                c1=xx.se;
            }
            if (xx.fi<b2)
            {
                b2=xx.fi;
                c2=xx.se;
            }
        }
        va[c1]=true;
        va[c2]=true;
    }
    for (int i=1;i<=n;i++)
    {
        if (va[i])cout<<1;
        else cout<<0;
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...