QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#312276 | #7926. Color Inversion on a Huge Chessboard | SocialPanda | TL | 299ms | 6684kb | C++14 | 544b | 2024-01-23 18:51:43 | 2024-01-23 18:51:44 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+100;
signed main()
{
string s;
int t;
int n,q;
cin>>n>>q;
int r[n+1],c[n+1];
for(int i=1;i<=n;i++)
{
if(i&1) r[i]=1,c[i]=1;
else r[i]=0,c[i]=0;
}
while(q--)
{
cin>>s>>t;
if(s=="ROW")
{
r[t]++;
}
else
{
c[t]++;
}
int xx=1,yy=1;
for(int i=1;i<=n-1;i++)
{
if(r[i]%2!=r[i+1]%2) xx++;
}
for(int i=1;i<=n-1;i++)
{
if(c[i]%2!=c[i+1]%2) yy++;
}
cout<<xx*yy<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
3 3 ROW 2 COLUMN 3 ROW 2
output:
3 2 6
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 6684kb
input:
200000 2 ROW 1 ROW 1
output:
39999800000 40000000000
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
1 1 COLUMN 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
1 100 COLUMN 1 COLUMN 1 ROW 1 ROW 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 ROW 1 COLUMN 1 COL...
output:
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
result:
ok 100 lines
Test #5:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
2 100 COLUMN 2 ROW 1 COLUMN 2 COLUMN 2 ROW 2 ROW 1 COLUMN 1 COLUMN 1 COLUMN 1 ROW 1 ROW 1 ROW 1 COLUMN 1 ROW 2 COLUMN 1 COLUMN 2 COLUMN 1 ROW 1 ROW 2 ROW 1 COLUMN 2 ROW 2 ROW 2 COLUMN 2 COLUMN 1 ROW 2 COLUMN 2 ROW 1 ROW 2 ROW 1 ROW 1 COLUMN 2 COLUMN 2 COLUMN 2 COLUMN 2 ROW 2 ROW 1 ROW 1 COLUMN 1 ROW...
output:
2 1 2 1 2 1 2 1 2 4 2 4 2 1 2 1 2 4 2 4 2 1 2 4 2 1 2 4 2 4 2 1 2 1 2 4 2 4 2 1 2 1 2 1 2 4 2 4 2 4 2 4 2 4 2 1 2 1 2 1 2 4 2 1 2 4 2 4 2 1 2 1 2 4 2 1 2 4 2 1 2 4 2 1 2 4 2 4 2 1 2 4 2 1 2 4 2 4 2 4
result:
ok 100 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
3 100 ROW 1 ROW 1 COLUMN 3 ROW 3 ROW 2 COLUMN 2 ROW 3 COLUMN 3 COLUMN 2 COLUMN 1 ROW 3 ROW 2 ROW 2 COLUMN 3 ROW 3 COLUMN 2 COLUMN 2 ROW 2 COLUMN 3 COLUMN 1 COLUMN 2 COLUMN 2 ROW 1 ROW 1 COLUMN 3 ROW 2 COLUMN 2 COLUMN 3 ROW 3 COLUMN 1 ROW 3 COLUMN 2 COLUMN 1 ROW 3 ROW 3 COLUMN 2 COLUMN 2 COLUMN 1 ROW...
output:
6 9 6 4 4 4 2 1 3 2 4 4 4 2 1 3 1 3 6 9 3 9 6 9 6 2 2 1 2 4 2 2 3 6 3 1 3 2 4 4 2 4 4 6 9 6 4 4 6 9 6 4 2 4 4 4 6 9 6 9 6 3 2 2 6 4 6 9 6 4 2 1 2 3 6 4 2 2 4 4 4 4 4 4 6 4 4 4 2 1 2 3 2 4 2 3 2 4 2 3
result:
ok 100 lines
Test #7:
score: 0
Accepted
time: 208ms
memory: 3732kb
input:
1 500000 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 ROW 1 ROW 1 ROW 1 COLUMN 1 ROW 1 COLUMN 1 ROW 1 COLUMN 1 ROW 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 ROW 1 COLUMN 1 ROW 1 ROW 1 COLUMN 1 COLUMN 1 COLUMN 1 ROW 1 COLUMN 1 COLUMN 1 ROW 1 ROW 1 ROW 1 ROW 1 ROW 1 COLUMN 1 ROW 1 ROW 1 COLUMN 1 ROW 1 COLUMN...
output:
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 1 1 ...
result:
ok 500000 lines
Test #8:
score: 0
Accepted
time: 299ms
memory: 3552kb
input:
100 500000 ROW 61 COLUMN 9 COLUMN 12 COLUMN 53 ROW 33 ROW 92 COLUMN 6 COLUMN 60 COLUMN 18 ROW 67 COLUMN 79 ROW 35 ROW 12 ROW 48 ROW 28 ROW 91 ROW 44 COLUMN 11 COLUMN 45 ROW 13 COLUMN 61 ROW 75 COLUMN 15 ROW 75 COLUMN 86 ROW 52 COLUMN 7 ROW 36 COLUMN 13 COLUMN 42 COLUMN 99 ROW 8 COLUMN 8 COLUMN 40 CO...
output:
9800 9604 9408 9212 9024 8836 8648 8460 8272 8096 7912 7740 7568 7396 7224 7224 7052 7052 6888 6888 6888 6720 6560 6724 6560 6400 6400 6400 6400 6240 6080 5928 6084 5928 5772 5928 5772 5616 5460 5304 5148 5016 4884 4884 4752 4680 4680 4550 4410 4284 4158 4032 3904 4026 4026 3894 3762 3762 3876 3876 ...
result:
ok 500000 lines
Test #9:
score: -100
Time Limit Exceeded
input:
500000 500000 COLUMN 402110 COLUMN 19563 COLUMN 9425 COLUMN 365025 ROW 189381 COLUMN 399979 COLUMN 233971 ROW 327398 ROW 222106 COLUMN 435101 COLUMN 345343 COLUMN 424895 ROW 62920 ROW 228188 ROW 90499 ROW 326252 COLUMN 96648 ROW 315146 ROW 62918 COLUMN 116109 ROW 213729 COLUMN 383506 ROW 142029 COLU...
output:
249999000000 249998000000 249997000000 249996000000 249995000016 249994000020 249993000024 249992000048 249991000072 249990000084 249989000096 249988000108 249987000144 249986000180 249985000216 249984000252 249983000280 249982000320 249981000360 249980000396 249979000440 249978000480 249977000528 2...