Submission #758061

# Submission time Handle Problem Language Result Execution time Memory
758061 2023-06-14T06:06:49 Z roCatalyst Towers (NOI22_towers) C++14
0 / 100
1430 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

vector<string> all;

void generate(string s, int N){
    if (N == 0) {
        all.push_back(s);
    } else {
        generate(s+'1',N-1);
        generate(s+'0',N-1);
    }
}

/*
all_perms = []

def generate(s,N):
    if N == 0:
        all_perms.append(s)
    else:
        generate(s+'0',N-1)
        generate(s+'1',N-1)

N = int(input())

generate("",N)
print(all_perms)
*/

int main() {
    int N;
    cin >> N;  
    /*generate("",N);*/


    vector<pair<int,int>> cities;

    int maxX = -1;
    int maxY = -1;
    for (int i = 0; i < N; i++) {
        int xi;
        int yi;
        cin >> xi >> yi;
        maxX = max(xi,maxX);
        maxY = max(yi,maxY);
        cities.push_back(make_pair(xi,yi));
    }

    int coords[maxX][maxY];
    for (int i = 0; i < maxX; i++) {
        for (int j = 0; j < maxY; j++) {
            coords[i][j] = -1;
        }
    }
    for (int i = 0; i < N; i++) {
        pair<int,int> ci = cities[i];

        coords[ci.first-1][ci.second-1] = i;
    }

    bool ans[N];

    for (int i = 0; i < maxX; i++) {
        int start = -1;
        int end = -1;
        for (int j = 0; j < maxY; j++) {
            int curr = coords[i][j];
            if (curr) {
                if (start != -1) {
                    start = curr;
                }
                end = curr;
            }
        }

        if (start != -1) {
            ans[start] = true;
            ans[end] = true;
        }
    }


    for (int i = 0; i < N; i++) {
        if (ans[i]) {
            cout << 1;
        } else {
            cout << 0;
        }
    }
    cout << endl;


}
# Verdict Execution time Memory Grader output
1 Runtime error 406 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 406 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 1624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1430 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 406 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 406 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 406 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -