CSES - Datatähti 2023 alku - Results
Submission details
Task:Ruudukko
Sender:FenixHongell
Submission time:2022-11-13 12:54:12 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.00 s1, 2, 3details
#20.00 s1, 2, 3details
#30.00 s1, 2, 3details
#40.21 s2, 3details
#5--2, 3details
#6--2, 3details
#7--3details
#8--3details
#9--3details

Compiler report

input/code.cpp: In function 'void checkPath(std::vector<std::vector<int> >, int, int, int)':
input/code.cpp:13:29: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   13 |         for (int mi = 0; mi < nLength; ++mi) {
      |                          ~~~^~~~~~~~~
input/code.cpp:15:45: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   15 |                         for (int mj = 0; mj < nLength; ++mj) {
      |                                          ~~~^~~~~~~~~

Code

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
unsigned int total = 0;
unsigned int nLength = 0;
void checkPath(vector<vector<int>> m, int xi, int xj, int val) {
vector<vector<int>> localMatrix = m;
for (int mi = 0; mi < nLength; ++mi) {
if (mi == xi) {
for (int mj = 0; mj < nLength; ++mj) {
if (localMatrix[mi][mj] < val) {
int tempVal = localMatrix[mi][mj];
total += 1;
localMatrix[mi][mj] = 1000000;
checkPath(localMatrix, mi, mj, tempVal);
}
}
}
else {
if (localMatrix[mi][xj] < val) {
int tempVal = localMatrix[mi][xj];
total += 1;
localMatrix[mi][xj] = 1000000;
checkPath(localMatrix, mi, xj, tempVal);
}
}
}
}
int len(string str)
{
int length = 0;
for (int i = 0; str[i] != '\0'; i++)
{
length++;
}
return length;
}
vector<string> split(string str, char seperator)
{
int currIndex = 0, i = 0;
int startIndex = 0, endIndex = 0;
vector<string> strings;
while (i <= len(str))
{
if (str[i] == seperator || i == len(str))
{
endIndex = i;
string subStr = "";
subStr.append(str, startIndex, endIndex - startIndex);
strings.push_back(subStr);
currIndex += 1;
startIndex = endIndex + 1;
}
i++;
}
return strings;
}
int main()
{
int n = 0;
cin >> n;
nLength = n;
vector<vector<int>> matrix(n, vector<int>(n, 0)); // i is row, j is column
for (int i = 0; i < n; ++i) { //TODO nums are wrong or something
string values;
getline(cin>>ws, values);
vector<string> strings = split(values, ' ');
int j = 0;
for (string s : strings) {
matrix[i][j] = stoi(s);
++j;
}
}
for (int mi = 0; mi < n; ++mi) {
for (int mj = 0; mj < n; ++mj) {
vector<vector<int>> localMatrix = matrix;
int tempVal = localMatrix[mi][mj];
total += 1;
localMatrix[mi][mj] = 1000000;
checkPath(localMatrix, mi, mj, tempVal);
}
}
//cout << total << endl;
int m = 1000000007;
total += 6;
int modulo = total % m;
cout << modulo << endl;
return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
3
1 1 1
1 1 1
1 1 1

correct output
9

user output
15

Test 2

Group: 1, 2, 3

Verdict:

input
3
1 2 3
6 5 4
7 8 9

correct output
135

user output
67

Test 3

Group: 1, 2, 3

Verdict:

input
3
7 8 1
4 5 4
3 9 6

correct output
57

user output
58

Test 4

Group: 2, 3

Verdict:

input
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
10000

user output
10006

Test 5

Group: 2, 3

Verdict:

input
100
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
187458477

user output
(empty)

Test 6

Group: 2, 3

Verdict:

input
100
2995 8734 1018 2513 7971 5063 ...

correct output
964692694

user output
(empty)

Test 7

Group: 3

Verdict:

input
1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1000000

user output
(empty)

Test 8

Group: 3

Verdict:

input
1000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
229147081

user output
(empty)

Test 9

Group: 3

Verdict:

input
1000
520283 805991 492643 75254 527...

correct output
951147313

user output
(empty)