QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#511340#6836. A Plus B Problemucup-team3474WA 0ms3820kbC++232.2kb2024-08-09 19:16:232024-08-09 19:16:24

Judging History

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

  • [2024-08-09 19:16:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-08-09 19:16:23]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>=(k);--i)
#define mem(a, b) memset(a,b,sizeof(a))
#define endl '\n'
#define pii pair<int,int>
#define int long long
#define lson (p<<1)
#define rson (p<<1|1)
const int mod=998244353, NMAX=1e6+5, INF=0x3f3f3f3f3f3f3f3f;
using namespace std;

void solve()
{
    int n, q;
    cin >> n >> q;
    vector <int> a(n+1), b(n+1), c(n+1), jw(n+2);
    per(i, n, 1) {
        char x;
        cin >> x;
        a[i] = x-'0';
    }
    per(i, n, 1) {
        char x;
        cin >> x;
        b[i] = x-'0';
    }
    rep(i, 1, n) {
        c[i] = (jw[i]+a[i]+b[i])%10;
        jw[i+1] = (jw[i]+a[i]+b[i])/10;
    }
    // per(i, n, 1) cout << jw[i]; cout << endl;
    rep(k, 1, q) {
        int r, i, d, cnt = 0;
        cin >> r >> i >> d;
        i = n-i+1;
        int cc = i;
        if(r == 1) {
            if(a[i] != d)
                cnt ++;
            a[i] = d;
            if((d + b[i] + jw[i])%10 != c[i])
                cnt ++, c[i] = (d + b[i] + jw[i])%10;
            if((d + b[i] + jw[i])/10 != jw[i+1]) {
                while(i <= n && (d + b[i] + jw[i])/10 != jw[i+1]) {
                    jw[i+1] ^= 1;
                    i ++, cnt ++;
                    c[i] = (c[i] + 9)%10;
                }
            }
        }
        else {
            if(b[i] != d)
                cnt ++;
            b[i] = d;
            if((d + a[i] + jw[i])%10 != c[i])
                cnt ++, c[i] = (d + a[i] + jw[i])%10;
            if((d + a[i] + jw[i])/10 != jw[i+1]) {
                while(i <= n && (d + a[i] + jw[i])/10 != jw[i+1]) {
                    jw[i+1] ^= 1;
                    i ++, cnt ++;
                    c[i] = (c[i] + 9)%10;
                }
            }
        }
// cout << "a: ";per(i, n, 1) cout << a[i]; cout << endl;
// cout << "b: ";per(i, n, 1) cout << b[i]; cout << endl;
// cout << "c: ";per(i, n, 1) cout << c[i]; cout << endl;
        cout << c[cc] << " " << cnt << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int _ = 1;
    while(_ --)
        solve();
    return 0;
}

详细

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3480kb

input:

1 1
1
1
1 1 9

output:

0 3

result:

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