QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#281957 | #7926. Color Inversion on a Huge Chessboard | Lynkcat# | RE | 58ms | 7924kb | C++20 | 1.3kb | 2023-12-11 07:51:40 | 2023-12-11 07:51:41 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N
using namespace std;
const int N=300005;
int n,m,h[N],w[N];
void BellaKira()
{
cin>>n>>m;
for (int i=1;i<=n;i++)
h[i]=i%2,w[i]=i%2;
int hx=n-1,hy=n-1;
while (m--)
{
string st;
cin>>st;
int x;
cin>>x;
if (st=="ROW")
{
if (x-1>=1) hx-=(h[x-1]^h[x]);
if (x+1<=n) hx-=(h[x+1]^h[x]);
h[x]^=1;
if (x-1>=1) hx+=(h[x-1]^h[x]);
if (x+1<=n) hx+=(h[x+1]^h[x]);
}
else
{
if (x-1>=1) hy-=(w[x-1]^w[x]);
if (x+1<=n) hy-=(w[x+1]^w[x]);
w[x]^=1;
if (x-1>=1) hy+=(w[x-1]^w[x]);
if (x+1<=n) hy+=(w[x+1]^w[x]);
}
cout<<(hx+1)*(hy+1)<<'\n';
}
}
signed main()
{
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
/*list:
1.mod 998244353 or 1e9+7 or ???
2.N
3.duipai shuju xingtai duoyidian
...
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5712kb
input:
3 3 ROW 2 COLUMN 3 ROW 2
output:
3 2 6
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 7924kb
input:
200000 2 ROW 1 ROW 1
output:
39999800000 40000000000
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 5604kb
input:
1 1 COLUMN 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5612kb
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: 5864kb
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: 1ms
memory: 5612kb
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: 50ms
memory: 5612kb
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: 58ms
memory: 5844kb
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
Runtime Error
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...