QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#40716#3860. Drone PhotoCasio991msWA 173ms30064kbC++1.1kb2022-07-24 18:55:492022-07-24 18:55:50

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-24 18:55:50]
  • 评测
  • 测评结果:WA
  • 用时:173ms
  • 内存:30064kb
  • [2022-07-24 18:55:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define ff first
#define ss second
#define show(x) cout << #x << ": " << x << "; "
#define MOD 1000000007
#define MAXN 2000006

int pos2age[1503][1503];
pii age2pos[2250006];
int rows[1503], columns[1503];

void solve(int caseno)
{
    int n, i, j, ans, youngerInRow, youngerInColumn;

    cin >> n;

    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= n; j++)
        {
            cin >> pos2age[i][j];
            age2pos[pos2age[i][j]] = {i, j};
        }
    }

    ans = 0;
    for(i = 1; i <= n*n; i++)
    {
        youngerInRow = rows[age2pos[i].ff];
        youngerInColumn = columns[age2pos[i].ss];

        ans += youngerInRow*(n-1- youngerInColumn) + youngerInColumn*(n-1-youngerInRow);

        rows[age2pos[i].ff]++;
        columns[age2pos[i].ss]++;
    }

    cout << ans/2 << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int T = 1, caseno = 0;

    // cin >> T;

    while(T--)
    {
        solve(++caseno);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5700kb

input:

2
1 3
4 2

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 3ms
memory: 5664kb

input:

2
3 2
4 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

3
9 2 4
1 5 3
7 8 6

output:

6

result:

ok single line: '6'

Test #4:

score: -100
Wrong Answer
time: 173ms
memory: 30064kb

input:

1500
2248501 2248502 2248503 2248504 2248505 2248506 2248507 2248508 2248509 2248510 2248511 2248512 2248513 2248514 2248515 2248516 2248517 2248518 2248519 2248520 2248521 2248522 2248523 2248524 2248525 2248526 2248527 2248528 2248529 2248530 2248531 2248532 2248533 2248534 2248535 2248536 2248537...

output:

-929806172

result:

wrong answer 1st lines differ - expected: '1263938062500', found: '-929806172'