QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#348975#6836. A Plus B ProblemstudentDLWA 57ms7904kbC++142.4kb2024-03-09 22:45:462024-03-09 22:45:47

Judging History

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

  • [2024-03-09 22:45:47]
  • 评测
  • 测评结果:WA
  • 用时:57ms
  • 内存:7904kb
  • [2024-03-09 22:45:46]
  • 提交

answer

#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
#define pii pair<int,int>
#define mk make_pair
#define ft first
#define se second
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define inf 1e18
using namespace std;
#define LOCAL
namespace IO{
    #ifndef LOCAL
        #define SIZE 30000
        char in[SIZE],out[SIZE],*p1=in,*p2=in,*p3=out;
        #define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,SIZE,stdin),p1==p2)?EOF:*p1++)
        #define flush() (fwrite(p3=out,1,SIZE,stdout))
        #define putchar(ch) (p3==out+SIZE&&flush(),*p3++=(ch))
        class Flush{public:~Flush(){fwrite(out,1,p3-out,stdout);}}_;
    #endif
    template<typename type>
    inline void read(type &x){
        x=0;bool flag=0;char ch=getchar();
        while(ch<'0'||ch>'9') flag^=ch=='-',ch=getchar();
        while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
        flag?x=-x:0;
    }
    template<typename type>
    inline void write(type x,char ch=0){
        x<0?x=-x,putchar('-'):0;static short Stack[50],top=0;
        do Stack[++top]=x%10,x/=10;while(x);
        while(top) putchar(Stack[top--]|48);
        if(ch) putchar(ch);
    }
}
using namespace IO;
#define M 1000005
int n,Q,a[2][M];
char num[M];
set<int> pos;
int main(){
    read(n),read(Q);
    scanf("%s",num+1);
    for(int i=1;i<=n;i++) a[0][i]=num[i]-'0';
    scanf("%s",num+1);
    for(int i=1;i<=n;i++){
        a[1][i]=num[i]-'0';
        if(a[0][i]+a[1][i]!=9) pos.insert(i);
    }
    while(Q--){
        int r,c,d;
        read(r),read(c),read(d),r--;
        int car=0;
        auto nxt=pos.upper_bound(c);
        if(nxt!=pos.end()&&a[0][*nxt]+a[1][*nxt]>9) car=1;
        int pre=a[0][c]+a[1][c]+car,now=a[r^1][c]+d+car;
        if(a[r][c]==d){
            write(now%10,' '),write(0,' ');
            continue;
        }
        if(now-car!=9) pos.insert(c);
        else if(pre-car==9) pos.erase(c);
        if(pre<10&&now<10){
            write(now,' '),write(2,'\n');
        }else if(pre>=10&&now>=10){
            write(now-10,' '),write(2,'\n');
        }else{
            auto prc=pos.lower_bound(c);
            int ppos=prc==pos.begin()?1:*(--prc);
            write(now%10,' '),write(1+c-ppos+1,'\n');
        }
        a[r][c]=d;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 5916kb

input:

1 1
1
1
1 1 9

output:

0 2

result:

ok single line: '0 2'

Test #3:

score: -100
Wrong Answer
time: 57ms
memory: 7904kb

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 3 2
2 8
4 2
6 2
2 2
4 2
6 5
6 3
2 4
7 2
2 2
8 2
1 2
5 2
1 3
2 3
8 3
8 2
2 2
6 2
1 3
3 3
7 2
7 3
0 2
9 3
6 4
0 0 1 3
4 2
7 3
0 3
8 3
8 3
8 2
2 0 3 3
0 3
2 3
5 2
9 2
4 2
8 2
3 3
5 3
3 2
5 0 4 2
3 2
1 2
4 2
7 3
0 2
5 2
6 2
0 3
4 2
4 2
3 2
5 3
6 3
3 0 8 2
9 3
9 3
1 2
1 3
7 2
5 2
5 2
4 0 0 2
...

result:

wrong answer 3rd lines differ - expected: '9 0', found: '9 0 3 2'