Codeforces Global Round 6

每日一场contest Day1
题目链接

A.

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=418+10;
string s;
int n[12];
void solve()
{
	for(int i=0;i<=9;i++) n[i]=0;
	cin>>s;
	int flag=0,sum=0;
	for(int i=0;i<s.size();i++)
	{
		int num=s[i]-'0';
		n[num]++;
		if(flag==0&&num%2==0&&num!=0) flag=1;
		sum+=num;
	}
	if(sum%3==0&&n[0]>=1)
	{
		if(flag==1||flag==0&&n[0]>=2) 
		{
			puts("red");
			return;
		}
	}
	puts("cyan");
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("hzh.in","r",stdin);
	//freopen("hzh.out","w",stdout);
	#endif
	ll T;
    rd(T);
    while(T--)
	solve();
    return 0;
}

1A

B.

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=418+10;
ll n;
void solve()
{
	rd(n);
	if(n>=15&&n%14<=6&&n%14>=1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("hzh.in","r",stdin);
	//freopen("hzh.out","w",stdout);
	#endif
	ll T;
    rd(T);
    while(T--)
	solve();
    return 0;
}

WA 1:题目没看清,以为能横着放
WA 2:极限情况未考虑(总和小于15的不可能)
WA 3:部分情况未考虑(余数不能为0)
WA 4:爆int范围
AC 5
(菜到怀疑人生)

C.

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=500+10;
ll n,m;
void solve()
{
	rd(n),rd(m);
	if(n==1&&m==1) puts("0");
	else
	{
		if(m==1)
		{
			for(int i=1;i<=n;i++) cout<<i+1<<endl;
			return;
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				cout<<i*(j+n)<<' ';
			}
			cout<<endl;
		}
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("hzh.in","r",stdin);
	//freopen("hzh.out","w",stdout);
	#endif
	/*
	ll T;
    rd(T);
    while(T--)
	*/
	solve();
    return 0;
}

WA 1:特殊情况未考虑(m=1)
AC 2

D.

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=1e5+10;
ll n,m,a[maxn];
struct node
{
	ll id,v;
}b[maxn],c[maxn];
struct node2
{
	ll f,s,v;
}ans[maxn];
ll bnum=0,cnum=0,ansnum=0,bst=1,cst=1;
void solve()
{
	rd(n),rd(m);
	while(m--)
	{
		ll x,y,v;
		rd(x),rd(y),rd(v);
		a[x]-=v;
		a[y]+=v;
	}
	for(ll i=1;i<=n;i++)
	{
		if(a[i]>0)
		{
			b[++bnum].id=i;
			b[bnum].v=a[i];
		}
		else if(a[i]<0)
		{
			c[++cnum].id=i;
			c[cnum].v=a[i];
		}
	}
	while(!(bst==bnum+1&&cst==cnum+1))
	{
		if(b[bst].v+c[cst].v==0)
		{
			ans[++ansnum].f=c[cst].id;
			ans[ansnum].s=b[bst].id;
			ans[ansnum].v=b[bst].v;
			bst++;
			cst++;
			continue;
		}
		if(b[bst].v+c[cst].v>0)
		{
			ans[++ansnum].f=c[cst].id;
			ans[ansnum].s=b[bst].id;
			ans[ansnum].v=(-c[cst].v);
			b[bst].v+=c[cst].v;
			cst++;
			continue;
		}
		if(b[bst].v+c[cst].v<0)
		{
			ans[++ansnum].f=c[cst].id;
			ans[ansnum].s=b[bst].id;
			ans[ansnum].v=b[bst].v;
			c[cst].v+=b[bst].v;
			bst++;
			continue;
		}
	}
	cout<<ansnum<<endl;
	for(ll i=1;i<=ansnum;i++)
		cout<<ans[i].f<<' '<<ans[i].s<<' '<<ans[i].v<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("hzh.in","r",stdin);
	//freopen("hzh.out","w",stdout);
	#endif
	/*
	ll T;
    rd(T);
    while(T--)
	*/
	solve();
    return 0;
}

WA 1:复制黏贴的时候,变量名没改(bst没改成cst)
AC 2

E.

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=2e5+10;
ll a[maxn],b[maxn];
map<ll,ll>m[maxn];
void solve()
{
	ll n,q,ans=0;
	rd(n);
	for(ll i=1;i<=n;i++) rd(a[i]),ans+=a[i];
	rd(q);
	while(q--)
	{
		ll s,t,u;
		rd(s),rd(t),rd(u);
		if(m[s][t]!=0)
		{
			b[m[s][t]]--;
			if(b[m[s][t]]<a[m[s][t]]) ans++;
		}
		if(u!=0)
		{
			b[u]++;
			if(b[u]<=a[u]) ans--;
		}
		m[s][t]=u;
		cout<<ans<<endl;
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("hzh.in","r",stdin);
	//freopen("hzh.out","w",stdout);
	#endif
	/*
	ll T;
    rd(T);
    while(T--)
	*/
	solve();
    return 0;
}

WA 1:爆int范围
AC 2
(菜鸟总是会在同一个坑上跌倒n次)

比赛感想:
虽然是virtual contest,但是第一次做到E还是挺开心的。
果然还是喜欢做算法竞赛,就算最后被踢出集训队也会努力坚持下去。

比赛总结:
1.把所有变量设为ll
2.看清题目,ABCD题这种不可能太复杂,不要想复杂了
3.考虑极限情况,要学会自己写一般样例和极限样例
4.复制黏贴的时候看清楚???说好的电子竞技不需要视力呢???
好几次WA都是老花眼看错了…QAQ
比较好的办法就是别复制,自己从头敲一遍好啦,仔细想想,每次复制代码都会出错,
所以就算是极为类似的代码段,也应该再敲一遍,以防万一。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值