| Task: | Ruudukko | 
| Sender: | Kemm1706 | 
| Submission time: | 2022-12-03 16:39:53 +0200 | 
| Language: | C++ (C++11) | 
| Status: | READY | 
| Result: | 61 | 
| group | verdict | score | 
|---|---|---|
| #1 | ACCEPTED | 28 | 
| #2 | ACCEPTED | 33 | 
| #3 | RUNTIME ERROR | 0 | 
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 1, 2, 3 | details | 
| #2 | ACCEPTED | 0.00 s | 1, 2, 3 | details | 
| #3 | ACCEPTED | 0.00 s | 1, 2, 3 | details | 
| #4 | ACCEPTED | 0.01 s | 2, 3 | details | 
| #5 | ACCEPTED | 0.01 s | 2, 3 | details | 
| #6 | ACCEPTED | 0.01 s | 2, 3 | details | 
| #7 | RUNTIME ERROR | 0.01 s | 3 | details | 
| #8 | RUNTIME ERROR | 0.01 s | 3 | details | 
| #9 | RUNTIME ERROR | 0.01 s | 3 | details | 
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: ACCEPTED
| input | 
|---|
| 3 1 1 1 1 1 1 1 1 1  | 
| correct output | 
|---|
| 9 | 
| user output | 
|---|
| 9 | 
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input | 
|---|
| 3 1 2 3 6 5 4 7 8 9  | 
| correct output | 
|---|
| 135 | 
| user output | 
|---|
| 135 | 
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
| input | 
|---|
| 3 7 8 1 4 5 4 3 9 6  | 
| correct output | 
|---|
| 57 | 
| user output | 
|---|
| 57 | 
Test 4
Group: 2, 3
Verdict: ACCEPTED
| input | 
|---|
| 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...  | 
| correct output | 
|---|
| 10000 | 
| user output | 
|---|
| 10000 | 
Test 5
Group: 2, 3
Verdict: ACCEPTED
| input | 
|---|
| 100 1 2 3 4 5 6 7 8 9 10 11 12 13 ...  | 
| correct output | 
|---|
| 187458477 | 
| user output | 
|---|
| 187458477 | 
Test 6
Group: 2, 3
Verdict: ACCEPTED
| input | 
|---|
| 100 2995 8734 1018 2513 7971 5063 ...  | 
| correct output | 
|---|
| 964692694 | 
| user output | 
|---|
| 964692694 | 
Test 7
Group: 3
Verdict: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| input | 
|---|
| 1000 520283 805991 492643 75254 527...  | 
| correct output | 
|---|
| 951147313 | 
| user output | 
|---|
| (empty) | 
