QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#261743#5456. Big PicturesupepapupuWA 1ms3592kbC++171.2kb2023-11-23 10:00:422023-11-23 10:00:42

Judging History

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

  • [2023-11-23 10:00:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2023-11-23 10:00:42]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
#define debug(x) cout << #x << ": " << x << el
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;

void inc(ll &a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

void dec(ll &a, ll b) {
    a -= b;
    if (a < 0) a += mod;
}

ll add(ll a, ll b) {
    a += b;
    return a >= mod ? a - mod : a;
}

ll del(ll a, ll b) {
    a -= b;
    return a < 0 ? a + mod : a;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<vector<ll>> p(n, vector<ll>(m));
    vector<vector<ll>> q(n, vector<ll>(m));
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
        cin >> p[i][j];
        if (j) p[i][j] += p[i][j - 1];
    }
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
        cin >> q[i][j];
        if (i) q[i][j] += q[i - 1][j];
    }
    ll ans = 2;
    for (int i = 1; i + 1 < n; ++i) for (int j = 1; j + 1 < m; ++j) {
        inc(ans, p[i][j - 1] * q[i - 1][j] % mod * del(1, p[i + 1][j - 1]) % mod * del(1, q[i - 1][j + 1]) % mod);
    }
    cout << ans << el;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3408kb

input:

3 3
0 0 1
1 0 0
0 0 1
0 1 0
0 0 0
1 0 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

2 2
499122177 499122177
499122177 499122177
499122177 499122177
499122177 499122177

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

3 3
332748118 332748118 332748118
332748118 332748118 332748118
332748118 332748118 332748118
332748118 332748118 332748118
332748118 332748118 332748118
332748118 332748118 332748118

output:

308100111

result:

ok 1 number(s): "308100111"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3380kb

input:

3 3
493467174 925495668 577525865
405223176 658993746 932271785
966780207 630353698 399354802
22358767 981331599 114314620
272795749 519599007 591379230
703089838 495558101 292550504

output:

23563191

result:

ok 1 number(s): "23563191"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3416kb

input:

3 4
493659548 347753380 41129357 115702069
790219615 554402002 99659402 552207688
7961216 627013784 223799162 139470192
329148825 491071064 379664791 105141924
498265681 675980390 393090456 957492234
170829848 829437253 225489107 933854549

output:

784737880

result:

ok 1 number(s): "784737880"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3592kb

input:

100 100
968816278 734173596 234681910 93630748 134697884 471229964 39013156 956757252 235131257 511081728 621947839 676193272 840439535 664182871 902176048 20092424 884007838 81431694 951304691 976244158 965161864 845777280 94028804 565315467 686041993 462628490 127799346 373093423 391855425 4867259...

output:

-28718044702

result:

wrong answer 1st numbers differ - expected: '674065285', found: '-28718044702'