QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#142397#5456. Big PictureElDiablo#AC ✓128ms18944kbC++141.3kb2023-08-19 01:38:222023-08-19 01:38:25

Judging History

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

  • [2023-08-19 01:38:25]
  • 评测
  • 测评结果:AC
  • 用时:128ms
  • 内存:18944kb
  • [2023-08-19 01:38:22]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
template<class T, class _Cmp = std::less<T>>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, _Cmp, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
#ifdef LOCAL
#include "debug.hpp"
#else 
#define debug(...) 
#endif
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 998244353;


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

    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> p(n + 1, vector<ll>(m + 1));
    vector<vector<ll>> q(n + 1, vector<ll>(m + 1));
    for (ll i = 1; i <= n; i++){
        for (ll j = 1; j <= m; j++){
            cin >> p[i][j];
            p[i][j] += p[i][j - 1];
            p[i][j] %= mod;
        }
    }
    for (ll i = 1; i <= n; i++){
        for (ll j = 1; j <= m; j++){
            cin >> q[i][j];
            q[i][j] += q[i - 1][j];
            q[i][j] %= mod;
        }
    }
    ll ans = 2;
    for (ll i = 2; i <= n; i++){
        for (ll j = 2; j <= m; j++){
            ans += (1 + mod - p[i][j - 2]) * (1 + mod - q[i - 2][j]) % mod * p[i - 1][j - 2] % mod * q[i - 2][j - 1] % mod;
            ans %= mod;
        }
    }
    cout << ans << "\n";

    return 0;
}

详细

Test #1:

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

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: 0ms
memory: 3520kb

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: 3572kb

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: 1ms
memory: 3456kb

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: 1ms
memory: 3460kb

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: 0
Accepted
time: 1ms
memory: 3684kb

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:

674065285

result:

ok 1 number(s): "674065285"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3892kb

input:

200 199
651700501 316888933 636760258 710519804 979635790 431517212 426271520 438606170 264014396 821432690 856532353 593193153 730369769 738218364 931314610 464183384 649108501 692856317 896419090 859042084 253545651 925218904 209204714 964720847 270465040 877213966 556600916 266109538 89025348 955...

output:

761582714

result:

ok 1 number(s): "761582714"

Test #8:

score: 0
Accepted
time: 2ms
memory: 3900kb

input:

199 200
855982177 899033137 857166748 154194180 491821489 936038701 3224246 36250618 98892048 302140015 794640536 416783706 127675016 405917998 810549418 512853897 794410341 751776756 962776697 437808995 42664926 617079413 287993531 754517649 196857387 98605924 437576034 405249986 501341390 9381807 ...

output:

23575883

result:

ok 1 number(s): "23575883"

Test #9:

score: 0
Accepted
time: 18ms
memory: 6232kb

input:

500 400
72515769 740084226 495955960 818627803 996233188 939336757 660769842 900083013 516811832 948688370 190983166 700755046 725666191 328442680 875581535 336718725 61207501 432805968 739541236 154531312 562430186 291869705 53196304 388792842 771217822 494695449 92141944 786309802 59729318 8289686...

output:

646310271

result:

ok 1 number(s): "646310271"

Test #10:

score: 0
Accepted
time: 114ms
memory: 18944kb

input:

1000 999
795650098 214468232 293238302 956472869 963508300 152950675 332778044 343814027 226283602 475129464 264926647 612915811 52220688 752047365 53207005 824854089 964440017 176446166 421148215 794524271 734053120 903086814 195743674 134468212 708339297 274493474 991647876 223649647 499895016 343...

output:

777267719

result:

ok 1 number(s): "777267719"

Test #11:

score: 0
Accepted
time: 105ms
memory: 18944kb

input:

999 1000
990078941 834513847 566770109 186987188 311749761 202816623 18178171 341799789 882531908 227919120 738756186 31713847 38448010 887427104 749097109 721772777 800574980 140838641 340760447 317536000 153645022 20203677 509441381 92386232 683428380 485171900 141082579 519803036 239407921 431904...

output:

797495799

result:

ok 1 number(s): "797495799"

Test #12:

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

input:

1 1000
865561477 72336177 512589404 659280480 729664705 332496264 10125067 162396209 337852118 235168352 745897162 624343408 680571458 406843703 593295102 463447303 875777949 65980904 986994648 123891087 299721718 487984705 833593382 879673048 20178491 596839074 66333708 72629381 989328440 610923886...

output:

2

result:

ok 1 number(s): "2"

Test #13:

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

input:

1000 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

2

result:

ok 1 number(s): "2"

Test #14:

score: 0
Accepted
time: 128ms
memory: 18876kb

input:

1000 1000
363404459 364033656 109262550 987419044 566850510 158677668 86765910 117668850 972431056 752990746 797824608 368896025 828777722 179827000 547989067 559543021 250055475 621118166 343014414 973968011 780219307 411784822 657282180 275541216 632340286 805660555 962920542 536482883 840886893 2...

output:

319243592

result:

ok 1 number(s): "319243592"