QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630162#6836. A Plus B Problemrxzfn639WA 0ms3812kbC++231.4kb2024-10-11 16:49:442024-10-11 16:49:45

Judging History

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

  • [2024-10-11 16:49:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3812kb
  • [2024-10-11 16:49:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 P = 998244353;
void solve() {
    int n, q;
    string s, t;
    cin >> n >> q >> s >> t;
    vector a(2, vector<int> (n + 1));
    for (int i = 0; i < n; i++) a[0][i + 1] = s[i] - '0';
    for (int i = 0; i < n; i++) a[1][i + 1] = t[i] - '0';
    set<int> st;
    for (int i = 0; i <= n; i++) {
        if (a[0][i] + a[1][i] != 9) st.insert(i);
    }
    while (q--) {
        int r, c, d, g = 0;
        cin >> r >> c >> d;
        r--;
        auto p1 = st.upper_bound(c);
        if (p1 != st.end() && a[0][*p1] + a[1][*p1] >= 10) {
            g = 1;
        } 
        cout << (a[r ^ 1][c] + d + g) % 10 << ' ';
        if (d == a[r][c]) {
            cout << 0 << '\n';
            return;
        }
        if ((a[r ^ 1][c] + a[r][c] + g) / 10 == (a[r ^ 1][c] + d + g) / 10) {
            cout << 2 << '\n';
        } else {
            int p2 = *prev(st.lower_bound(c));
            int ans = c - p2 + 1;
            if (p2 == 0) ans--;
            cout << ans + 1 << '\n';
        }
        if (a[r ^ 1][c] + a[r][c] != 9) st.erase(c);
        a[r][c] = d;
        if (a[r ^ 1][c] + a[r][c] != 9) st.insert(c);
    }
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int t = 1; 
    // cin >> t;
    while(t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 5
01234
56789
2 1 0
2 2 1
2 3 2
2 4 3
2 5 4

output:

0 2
3 2
5 3
7 3
8 3

result:

ok 5 lines

Test #2:

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

input:

1 1
1
1
1 1 9

output:

0 2

result:

ok single line: '0 2'

Test #3:

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

input:

10 1000000
6869373857
3130626142
1 9 2
1 10 0
2 7 6
1 1 0
1 7 6
2 10 4
2 3 9
2 4 2
2 4 4
2 7 0
1 2 4
1 9 8
1 3 7
1 7 1
1 1 5
2 1 6
1 3 5
2 5 8
2 6 5
1 6 3
1 3 8
2 4 2
2 6 3
2 2 6
1 10 9
2 1 1
2 5 4
1 1 8
2 4 0
1 9 1
1 1 8
2 4 2
2 9 2
1 10 3
1 8 9
1 4 6
2 3 0
1 1 6
1 7 1
1 10 9
2 4 4
2 5 9
2 1 8
1 9 ...

output:

6 2
2 2
9 0

result:

wrong answer 4th lines differ - expected: '3 2', found: ''