首页 > 其他 > 详细

Codeforces Round #696 (Div. 2) A. Puzzle From the Fut

时间:2021-01-20 09:34:47      阅读:48      评论:0      收藏:0      [点我收藏+]

Codeforces Round #696 (Div. 2) A. Puzzle From the Future

[原题链接](Problem - A - Codeforces)

AC代码:

#include<bits/stdc++.h>
using namespace std;
#define io ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

const int N = 1e6 + 1000;
int a[N], b[N];
int t, n;
int main(){
    io;
    cin >> t;
    while(t--){
    	string s;
    	cin >> n >> s;
    	for(int i = 0; i < s.length(); i++){
    		if(s[i] == ‘0‘) a[i] = 0;
    		else a[i] = 1;
    		b[i] = 0;
    	}
    	b[0] = 1;
    	for(int i = 1; i < n; i++){
    		if(a[i] + 1 == a[i - 1] + b[i - 1]) b[i] = 0;
    		else if(a[i] + 1 != a[i - 1] + b[i - 1]) b[i] = 1;
    	} 
    	
    	for(int i = 0; i < n; i++) cout << b[i];
    	cout << endl;
    }

    return 0;
}

Codeforces Round #696 (Div. 2) A. Puzzle From the Fut

原文:https://www.cnblogs.com/FrankOu/p/14300821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!