QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#494047#7926. Color Inversion on a Huge ChessboardNew_Folder#WA 1ms6312kbC++142.6kb2024-07-27 13:53:282024-07-27 13:53:28

Judging History

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

  • [2024-07-27 13:53:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6312kb
  • [2024-07-27 13:53:28]
  • 提交

answer

#pragma GCC optimize(2)
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int row[500001];
int col[500001];
void solve()
{
    ll n, q;
    cin >> n >> q;
    for (int i = 1; i <= n;i+=2){
        row[i] = 1;
        col[i] = 1;
    }
    ll r = n;
    ll c = n;
    while(q--){
        string s;
        cin >> s;
        int index;
        cin >> index;
        if(s[0]=='R'){
            if(index==1){
                if(row[index]!=row[index+1]){
                    r--;
                }else{
                    r++;
                }
                row[index] ^= 1;
                ll ans = r * c;
                cout << ans << '\n';
            }else if(index==n){
                if (row[index] != row[index - 1])
                {
                    r--;
                }
                else
                {
                    r++;
                }
                row[index] ^= 1;
                ll ans = r * c;
                cout << ans << '\n';
            }else{
                int dif = 0;
                dif += row[index] != row[index - 1];
                dif += row[index] != row[index + 1];
                row[index] ^= 1;
                r += 2 - 2 * dif;
                ll ans = r * c;
                cout << ans << '\n';
            }
        }else{
            if (index == 1)
            {
                if (col[index] != col[index + 1])
                {
                    c--;
                }
                else
                {
                    c++;
                }
                col[index] ^= 1;
                ll ans = r * c;
                cout << ans << '\n';
            }
            else if (index == n)
            {
                if (col[index] != col[index - 1])
                {
                    c--;
                }
                else
                {
                    c++;
                }
                col[index] ^= 1;
                ll ans = r * c;
                cout << ans << '\n';
            }
            else
            {
                int dif = 0;
                dif += col[index] != col[index - 1];
                dif += col[index] != col[index + 1];
                col[index] ^= 1;
                c += 2 - 2 * dif;
                ll ans = r * c;
                cout << ans << '\n';
            }
        }
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

200000 2
ROW 1
ROW 1

output:

39999800000
40000000000

result:

ok 2 lines

Test #3:

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

input:

1 1
COLUMN 1

output:

0

result:

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