CSES - Datatähti 2023 alku - Results
Submission details
Task:Ruudukko
Sender:Kemm1706
Submission time:2022-12-03 16:39:28 +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.00 s2, 3details
#50.00 s2, 3details
#60.00 s2, 3details
#70.00 s3details
#80.00 s3details
#90.00 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen("test_input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL modd = 1e9 + 7;

struct Sq
{
    LL val, x, y;
};

bool SoSanh(Sq a, Sq b)
{
    return a.val < b.val;
}

LL Cal(LL a[100][100], LL x, LL y, LL n)
{
    LL r, ans = 0;
    for(r = 0; r < x; r++)
        ans += a[r][y];
    for(r = x + 1; r < n; r++)
        ans += a[r][y];
    for(r = 0; r < y; r++)
        ans += a[x][r];
    for(r = y + 1; r < n; r++)
        ans += a[x][r];
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    freopen("test_input.txt", "r", stdin);

    static LL a[100][100];
    static LL draft[100][100];
    static Sq k[10000];
    LL n, i, j, m = 0, s, ans = 0, x, y;
    cin >> n;
    for(i = 0; i < n; i++)
        for(j = 0; j < n; j++)
        {
            cin >> k[m].val;
            k[m].x = i;
            k[m].y = j;
            m++;
        }
    sort(k, k + m, SoSanh);
    i = 0;
    while(i < m && j < m)
    {
        j = i;
        vector <pair<LL, LL>> v;
        while(k[j].val == k[i].val && j < m)
        {
            x = k[j].x;
            y = k[j].y;
            v.push_back({x, y});
            draft[x][y] = Cal(a, x, y, n);
            draft[x][y]++;
            draft[x][y] %= modd;
            j++;
        }
        i = j;
        s = v.size();
        for(j = 0; j < s; j++)
            a[v[j].first][v[j].second] = draft[v[j].first][v[j].second];
    }
    /*for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
            cout << a[i][j];
        cout << "\n";
    }*/
    for(i = 0; i < n; i++)
        for(j = 0; j < n; j++)
        {
            ans += a[i][j];
            ans %= modd;
        }
    cout << ans;
    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
(empty)

Test 2

Group: 1, 2, 3

Verdict:

input
3
1 2 3
6 5 4
7 8 9

correct output
135

user output
(empty)

Test 3

Group: 1, 2, 3

Verdict:

input
3
7 8 1
4 5 4
3 9 6

correct output
57

user output
(empty)

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
(empty)

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)