QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#415492#7926. Color Inversion on a Huge Chessboard36champWA 1ms3648kbC++201.4kb2024-05-20 22:15:232024-05-20 22:15:24

Judging History

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

  • [2024-05-20 22:15:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3648kb
  • [2024-05-20 22:15:23]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

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

	int n, q;
	cin >> n >> q;

	ll R = n, C = n;
	vector<bool> r(n+1), c(n+1);
	for(int i=1; i<=n; i++)
    {
        r[i] = i % 2;
        c[i] = i % 2;
    }

    while(q-->0)
    {
        string s;
        int k;

        cin >> s >> k;

        if(s=="ROW")
        {
            if(k==1)
            {
                if(r[k] == r[k+1]) R++;
                else R--;
            }
            else if(k==n)
            {
                if(r[k] == r[k-1]) R++;
                else R--;
            }
            else
            {
                if(r[k-1] == r[k] && r[k] == r[k+1]) R+=2;
                else if(r[k-1] != r[k] && r[k] != r[k+1]) R-=2;
            }

            r[k] = !r[k];
        }
        else
        {
            if(k==1)
            {
                if(c[k] == c[k+1]) C++;
                else C--;
            }
            else if(k==n)
            {
                if(c[k] == c[k-1]) C++;
                else C--;
            }
            else
            {
                if(c[k-1] == c[k] && c[k] == c[k+1]) C+=2;
                else if(c[k-1] != c[k] && c[k] != c[k+1]) C-=2;
            }

            c[k] = !c[k];
        }

        cout << R * C << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

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

input:

200000 2
ROW 1
ROW 1

output:

39999800000
40000000000

result:

ok 2 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3604kb

input:

1 1
COLUMN 1

output:

0

result:

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