Atcoder beginner contest 055 solution

A.Restaurant
水题不解释

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	cout<<800*n-200*(n/15);
	return 0;
}

B.Training Camp
水题二连

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n;
ll ans=1; 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(ll i=2;i<=n;i++)
		ans=(ans%mod*i)%mod;
	cout<<ans;
	return 0;
}

C.Scc Puzzle
水题三连???为什么我最近打比赛遇不到这么水的了??

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll n,m;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	if(n>=m)
		cout<<m/2;
	else
		cout<<n+(m-n*2)/4;
	return 0;
}

D.Menagerie
dfs枚举所有情况,如果可行,最后判断一下。

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+10;
bool f=false;
int n,a[maxn];
char s[maxn];

int check(int i,int x){
	int l=i-1,r=i+1;
	if(i==1)
		l=n;
	if(i==n)
		r=1;
	if(x){
		if((s[i]=='o'&&a[r]!=a[l])||(s[i]=='x'&&a[r]==a[l]))
			return true;
		else
			return false;
	}
	else{
		if((s[i]=='o'&&a[r]==a[l])||(s[i]=='x'&&a[r]!=a[l]))
			return true;
		else
			return false;
	}
}

void dfs(int dep,int x){
	if(f)
		return ;
	a[dep]=x;
	if(dep>n)
		return ;
	if(n==dep&&check(dep,x)&&check(1,a[1])){
		f=true;
		return ;
	}
	if(x){
		if(s[dep]=='o')
			dfs(dep+1,a[dep-1]^1);
		else
			dfs(dep+1,a[dep-1]);
	}
	else{
		if(s[dep]=='o')
			dfs(dep+1,a[dep-1]);
		else
			dfs(dep+1,a[dep-1]^1);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	cin>>s+1;
	a[1]=1;
	dfs(2,1);
	if(!f){
		mm(a,0);
		a[1]=1;
		dfs(2,0);
	}
	if(!f){
		mm(a,0);
		a[1]=0;
		dfs(2,0);
	}
	if(!f){
		mm(a,0);
		a[1]=0;
		dfs(2,1);
	}
	if(f){
		for(int i=1;i<=n;i++){
			if(a[i])
				cout<<"W";
			else
				cout<<"S";
		}
	}
	else
		cout<<-1;
	cout<<"\n";
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值