QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#348970#6836. A Plus B ProblemstudentDLWA 1ms7900kbC++142.3kb2024-03-09 22:44:102024-03-09 22:44:12

Judging History

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

  • [2024-03-09 22:44:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7900kb
  • [2024-03-09 22:44:10]
  • 提交

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,' '),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,' '),write(2,'\n');
        }else{
            auto prc=pos.lower_bound(c);
            int ppos=prc==pos.begin()?0:*(--prc);
            write(now,' '),write(1+c-ppos+1,'\n');
        }
        a[r][c]=d;
    }
    return 0;
}

詳細信息

Test #1:

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

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

input:

1 1
1
1
1 1 9

output:

10 3

result:

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