Submission #758059

# Submission time Handle Problem Language Result Execution time Memory
758059 2023-06-14T06:01:47 Z roCatalyst Towers (NOI22_towers) C++14
0 / 100
985 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;
            }
        }
        ans[start] = true;
        ans[end] = true;
    }


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


}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:76:18: warning: array subscript -1 is below array bounds of 'bool [(<anonymous> + 1)]' [-Warray-bounds]
   76 |         ans[start] = true;
      |         ~~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Runtime error 424 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 424 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 985 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 424 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 424 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 424 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -