답안 #802880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
802880 2023-08-02T15:30:21 Z Theo830 Towers (NOI22_towers) C++17
5 / 100
2000 ms 302360 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define F first
#define S second
const ll N = 1e6+5;
int main(){
    set<ii>x[N],y[N];
    ll n;
    cin>>n;
    ll ans[n] = {0};
    set<iii>ek;
    f(i,0,n){
        ll a,b;
        cin>>a>>b;
        ek.insert(iii(i,ii(a,b)));
        x[a].insert(ii(b,i));
        y[b].insert(ii(a,i));
    }
    while(!ek.empty()){
        auto it = ek.begin();
        ll a = (*it).S.F,b = (*it).S.S;
        if(x[a].size() > 1){
            for(auto z:x[a]){
                ek.erase(iii(z.S,ii(a,z.F)));
                y[z.F].erase(ii(a,z.S));
            }
            ii A = (*x[a].begin()),B = (*x[a].rbegin());
            ans[A.S] = ans[B.S] = 1;
            x[a].clear();
            y[A.F].insert(ii(a,A.S));
            y[B.F].insert(ii(a,B.S));
        }
        else if(y[b].size() > 1){
            for(auto z:y[b]){
                ek.erase(iii(z.S,ii(z.F,b)));
                x[z.F].erase(ii(b,z.S));
            }
            ii A = (*y[b].begin()),B = (*y[b].rbegin());
            ans[A.S] = ans[B.S] = 1;
            y[b].clear();
            x[A.F].insert(ii(b,A.S));
            x[B.F].insert(ii(b,B.S));
        }
        else{
            ans[(*it).F] = 1;
            ek.erase((*it));
        }
    }
    f(i,0,n){
        cout<<ans[i];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 94208 KB Output is correct
2 Correct 43 ms 94164 KB Output is correct
3 Correct 46 ms 94284 KB Output is correct
4 Correct 44 ms 94216 KB Output is correct
5 Correct 44 ms 94208 KB Output is correct
6 Correct 45 ms 94212 KB Output is correct
7 Correct 51 ms 94220 KB Output is correct
8 Correct 43 ms 94204 KB Output is correct
9 Correct 44 ms 94212 KB Output is correct
10 Correct 49 ms 94208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 94208 KB Output is correct
2 Correct 43 ms 94164 KB Output is correct
3 Correct 46 ms 94284 KB Output is correct
4 Correct 44 ms 94216 KB Output is correct
5 Correct 44 ms 94208 KB Output is correct
6 Correct 45 ms 94212 KB Output is correct
7 Correct 51 ms 94220 KB Output is correct
8 Correct 43 ms 94204 KB Output is correct
9 Correct 44 ms 94212 KB Output is correct
10 Correct 49 ms 94208 KB Output is correct
11 Incorrect 45 ms 94200 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 124 ms 112992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2065 ms 302360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 94208 KB Output is correct
2 Correct 43 ms 94164 KB Output is correct
3 Correct 46 ms 94284 KB Output is correct
4 Correct 44 ms 94216 KB Output is correct
5 Correct 44 ms 94208 KB Output is correct
6 Correct 45 ms 94212 KB Output is correct
7 Correct 51 ms 94220 KB Output is correct
8 Correct 43 ms 94204 KB Output is correct
9 Correct 44 ms 94212 KB Output is correct
10 Correct 49 ms 94208 KB Output is correct
11 Incorrect 45 ms 94200 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 94208 KB Output is correct
2 Correct 43 ms 94164 KB Output is correct
3 Correct 46 ms 94284 KB Output is correct
4 Correct 44 ms 94216 KB Output is correct
5 Correct 44 ms 94208 KB Output is correct
6 Correct 45 ms 94212 KB Output is correct
7 Correct 51 ms 94220 KB Output is correct
8 Correct 43 ms 94204 KB Output is correct
9 Correct 44 ms 94212 KB Output is correct
10 Correct 49 ms 94208 KB Output is correct
11 Incorrect 45 ms 94200 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 94208 KB Output is correct
2 Correct 43 ms 94164 KB Output is correct
3 Correct 46 ms 94284 KB Output is correct
4 Correct 44 ms 94216 KB Output is correct
5 Correct 44 ms 94208 KB Output is correct
6 Correct 45 ms 94212 KB Output is correct
7 Correct 51 ms 94220 KB Output is correct
8 Correct 43 ms 94204 KB Output is correct
9 Correct 44 ms 94212 KB Output is correct
10 Correct 49 ms 94208 KB Output is correct
11 Incorrect 45 ms 94200 KB Output isn't correct
12 Halted 0 ms 0 KB -