답안 #749569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749569 2023-05-28T08:28:16 Z 반딧불(#9967) Towers (NOI22_towers) C++17
16 / 100
2000 ms 40920 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Point{
    int x, y, i;
    Point(){}
    Point(int x, int y, int i): x(x), y(y), i(i){}

    bool operator<(const Point &r)const{
        if(x!=r.x) return x<r.x;
        return y<r.y;
    }
};

int n;
Point arr[1000002];
int x[1000002], y[1000002];
bool ans[1000002];

int L[1000002], R[1000002], U[1000002], D[1000002];
int cntx[1000002], cnty[1000002];

bool good(int bit){
    vector<bool> on (n);
    for(int i=0; i<n; i++){
        if((bit>>i)&1){
            on[i] = 1;
            L[y[i]] = min(L[y[i]], x[i]);
            R[y[i]] = max(R[y[i]], x[i]);
            D[x[i]] = min(D[x[i]], y[i]);
            U[x[i]] = max(U[x[i]], y[i]);
            cntx[x[i]]++, cnty[y[i]]++;
        }
    }
    bool ret = 1;
    for(int i=0; i<n; i++){
        if((bit>>i)&1) continue;
        if(L[y[i]] < x[i] && x[i] < R[y[i]]) continue;
        if(D[x[i]] < y[i] && y[i] < U[x[i]]) continue;
        ret = 0;
    }

    for(int i=0; i<n; i++) if(cntx[x[i]] > 2 || cnty[y[i]] > 2) ret = 0;

    for(int i=0; i<n; i++){
        L[y[i]] = 1e9, R[y[i]] = 0;
        D[x[i]] = 1e9, U[x[i]] = 0;
        cntx[x[i]] = cnty[y[i]] = 0;
    }
    return ret;
}

int main(){
    for(int i=0; i<=1000000; i++) L[i] = D[i] = 1e9, R[i] = U[i] = 0;

    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d %d", &arr[i].x, &arr[i].y);
        arr[i].i = i;
        x[i] = arr[i].x, y[i] = arr[i].y;
    }

    for(int b=0; b<(1<<n); b++) if(good(b)){
        for(int i=0; i<n; i++) if((b>>i)&1) ans[i] = 1;
        break;
    }

    for(int i=0; i<n; i++) printf("%d", ans[i]);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         scanf("%d %d", &arr[i].x, &arr[i].y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 15956 KB Output is correct
2 Correct 8 ms 15956 KB Output is correct
3 Correct 8 ms 15956 KB Output is correct
4 Correct 8 ms 15972 KB Output is correct
5 Correct 7 ms 16020 KB Output is correct
6 Correct 8 ms 15956 KB Output is correct
7 Correct 9 ms 15956 KB Output is correct
8 Correct 8 ms 15956 KB Output is correct
9 Correct 7 ms 15968 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 15956 KB Output is correct
2 Correct 8 ms 15956 KB Output is correct
3 Correct 8 ms 15956 KB Output is correct
4 Correct 8 ms 15972 KB Output is correct
5 Correct 7 ms 16020 KB Output is correct
6 Correct 8 ms 15956 KB Output is correct
7 Correct 9 ms 15956 KB Output is correct
8 Correct 8 ms 15956 KB Output is correct
9 Correct 7 ms 15968 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 20 ms 15988 KB Output is correct
12 Correct 12 ms 15956 KB Output is correct
13 Correct 22 ms 15956 KB Output is correct
14 Correct 21 ms 16060 KB Output is correct
15 Correct 24 ms 15956 KB Output is correct
16 Correct 13 ms 15956 KB Output is correct
17 Correct 17 ms 16048 KB Output is correct
18 Correct 25 ms 15956 KB Output is correct
19 Correct 13 ms 16044 KB Output is correct
20 Correct 21 ms 16052 KB Output is correct
21 Correct 11 ms 16028 KB Output is correct
22 Correct 12 ms 15956 KB Output is correct
23 Correct 12 ms 16036 KB Output is correct
24 Correct 10 ms 15956 KB Output is correct
25 Correct 19 ms 15964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2076 ms 18044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 264 ms 40920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 15956 KB Output is correct
2 Correct 8 ms 15956 KB Output is correct
3 Correct 8 ms 15956 KB Output is correct
4 Correct 8 ms 15972 KB Output is correct
5 Correct 7 ms 16020 KB Output is correct
6 Correct 8 ms 15956 KB Output is correct
7 Correct 9 ms 15956 KB Output is correct
8 Correct 8 ms 15956 KB Output is correct
9 Correct 7 ms 15968 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 20 ms 15988 KB Output is correct
12 Correct 12 ms 15956 KB Output is correct
13 Correct 22 ms 15956 KB Output is correct
14 Correct 21 ms 16060 KB Output is correct
15 Correct 24 ms 15956 KB Output is correct
16 Correct 13 ms 15956 KB Output is correct
17 Correct 17 ms 16048 KB Output is correct
18 Correct 25 ms 15956 KB Output is correct
19 Correct 13 ms 16044 KB Output is correct
20 Correct 21 ms 16052 KB Output is correct
21 Correct 11 ms 16028 KB Output is correct
22 Correct 12 ms 15956 KB Output is correct
23 Correct 12 ms 16036 KB Output is correct
24 Correct 10 ms 15956 KB Output is correct
25 Correct 19 ms 15964 KB Output is correct
26 Incorrect 69 ms 23884 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 15956 KB Output is correct
2 Correct 8 ms 15956 KB Output is correct
3 Correct 8 ms 15956 KB Output is correct
4 Correct 8 ms 15972 KB Output is correct
5 Correct 7 ms 16020 KB Output is correct
6 Correct 8 ms 15956 KB Output is correct
7 Correct 9 ms 15956 KB Output is correct
8 Correct 8 ms 15956 KB Output is correct
9 Correct 7 ms 15968 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 20 ms 15988 KB Output is correct
12 Correct 12 ms 15956 KB Output is correct
13 Correct 22 ms 15956 KB Output is correct
14 Correct 21 ms 16060 KB Output is correct
15 Correct 24 ms 15956 KB Output is correct
16 Correct 13 ms 15956 KB Output is correct
17 Correct 17 ms 16048 KB Output is correct
18 Correct 25 ms 15956 KB Output is correct
19 Correct 13 ms 16044 KB Output is correct
20 Correct 21 ms 16052 KB Output is correct
21 Correct 11 ms 16028 KB Output is correct
22 Correct 12 ms 15956 KB Output is correct
23 Correct 12 ms 16036 KB Output is correct
24 Correct 10 ms 15956 KB Output is correct
25 Correct 19 ms 15964 KB Output is correct
26 Incorrect 69 ms 23884 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 15956 KB Output is correct
2 Correct 8 ms 15956 KB Output is correct
3 Correct 8 ms 15956 KB Output is correct
4 Correct 8 ms 15972 KB Output is correct
5 Correct 7 ms 16020 KB Output is correct
6 Correct 8 ms 15956 KB Output is correct
7 Correct 9 ms 15956 KB Output is correct
8 Correct 8 ms 15956 KB Output is correct
9 Correct 7 ms 15968 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 20 ms 15988 KB Output is correct
12 Correct 12 ms 15956 KB Output is correct
13 Correct 22 ms 15956 KB Output is correct
14 Correct 21 ms 16060 KB Output is correct
15 Correct 24 ms 15956 KB Output is correct
16 Correct 13 ms 15956 KB Output is correct
17 Correct 17 ms 16048 KB Output is correct
18 Correct 25 ms 15956 KB Output is correct
19 Correct 13 ms 16044 KB Output is correct
20 Correct 21 ms 16052 KB Output is correct
21 Correct 11 ms 16028 KB Output is correct
22 Correct 12 ms 15956 KB Output is correct
23 Correct 12 ms 16036 KB Output is correct
24 Correct 10 ms 15956 KB Output is correct
25 Correct 19 ms 15964 KB Output is correct
26 Execution timed out 2076 ms 18044 KB Time limit exceeded
27 Halted 0 ms 0 KB -