Codeforces Round 911 (Div. 2)

A.理解题意即可,就是如果3个“。”在一起就只需要倒2次水(在左边放一桶,在右边放一桶),(无限水!)ans=2;(然后一直拿中间的水给其他空加水就好了),如果没有3个“。”在一起,就得遇到"。"就ans++;

// Problem: A. Cover in Water
// Contest: Codeforces - Codeforces Round 911 (Div. 2)
// URL: https://codeforces.com/contest/1900/problem/0
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void solve() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i> q;
	while (q--) {
		solve();
	}

	return 0;
}

#############################################################################B.1,3变成2,1,2变成3,2,3变成1.(可以发现用xor就可以实现这个结果)(位运算)(这块真妙)因此只要模拟即可得到结果.

// Problem: B. Laura and Operations
// Contest: Codeforces - Codeforces Round 911 (Div. 2)
// URL: https://codeforces.com/contest/1900/problem/B
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
void solve() {
	int a,b,c;
	cin>>a>>b>>c;
	int ans=0;
	for(int i=1;i<=a;i++){
		ans^=1;
	}
	for(int i=1;i<=b;i++){
		ans^=2;
	}
	for(int i=1;i<=c;i++){
		ans^=3;
	}
	if(ans==0){
		cout<<1<<" "<<1<<" "<<1;
	}
	if(ans==1){
		cout<<1<<" "<<0<<" "<<0;
	}
	if(ans==2){
		cout<<0<<" "<<1<<" "<<0;
	}
	if(ans==3){
		cout<<0<<" "<<0<<" "<<1;
	}
	cout<<'\n';
}


int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

C.

你可能感兴趣的:(算法)