CSES - Datatähti 2023 alku - Results
Submission details
Task:Ruudukko
Sender:lompakkomies
Submission time:2022-11-02 18:45:05 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:14:5: error: 'vector' was not declared in this scope
   14 |     vector<vector<int>> vec;
      |     ^~~~~~
input/code.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
input/code.cpp:14:19: error: expected primary-expression before 'int'
   14 |     vector<vector<int>> vec;
      |                   ^~~

Code

#include <iostream>
using namespace std;

int main() {

    int n = 0;
    int temp = 0;

    cin >> n;

    int arr[1000][1000];
    int arr2[1000][1000];

    vector<vector<int>> vec;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> temp;
            arr[i][j] = temp;
            arr2[i][j] = 1;
        }
    }

    for (int i = 2; i <= n * n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (arr[j][k] == i) {
                    for (int l = 0; l < n; l++) {
                        if (arr[j][l] < i) {
                            arr2[j][k] = (arr2[j][k] + arr2[j][l]) % 1000000007;
                        }
                    }
                    for (int l = 0; l < n; l++) {
                        if (arr[l][k] < i) {
                            arr2[j][k] = (arr2[j][k] + arr2[l][k]) % 1000000007;
                        }
                    }
                }
            }
        }
    }

    int sum = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            sum = (sum + arr2[i][j]) % 1000000007;
        }
    }

    cout << sum;

}