首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【队伍训练】Codeforces Round #660 (Div. 2)

【队伍训练】Codeforces Round #660 (Div. 2)

作者头像
杨鹏伟
发布2020-09-11 15:12:34
3080
发布2020-09-11 15:12:34
举报
文章被收录于专栏:ypwypw

A 思维

#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1e9 + 7;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();    return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }
int main(){
    int t;
    cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	if(n<=30) cout<<"NO"<<endl;
    	else if(n==36) cout<<"YES\n"<<"5 6 10 15"<<endl;
    	else if (n==40) cout<<"YES\n"<<"2 6 10 22"<<endl;
		else if (n==44) cout<<"YES\n"<<"2 6 10 26"<<endl;
		else cout<<"YES\n"<<"6 10 14 "<<n-30<<endl;
	}
} 

B 观察

#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1e9 + 7;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();    return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

int main(){
	int t;
	cin>>t;
	int n;
	while(t--){
		cin>>n;
		int len=4*n-n;
		for (int i=0;i<(len/4);i++) cout<<9;
		for (int i=(len/4);i<n;i++) cout<<8;	
		cout<<endl;
	}
	return 0;
}

C dfs 这题卡时间较长

#include<bits/stdc++.h>
#define maxn 100100
using namespace std;

vector<int> g[maxn];
int happy[maxn];
int all[maxn];
int diff[maxn];
int flag;

int f;

void dfs(int v, int p) {
	int h = 0,k = 0;
	for (auto u : g[v]){
		k += 1;
		if (u == p) {
			continue;
		}
		dfs(u, v);
		all[v] += all[u];
		h += happy[u];
	}
	happy[v] = all[v] - (all[v] - diff[v]) / 2;
	
	if (happy[v] < h || happy[v]<0||happy[v]>all[v] || all[v]%2!=(diff[v]%2+2)%2) {
		f = 0;
	}
	
}
 
int main(){
	int t;
	cin>>t;
	while(t--){
		f = 1;
		int n,m;
		cin>>n>>m;
		for (int i = 0; i < n; i++) {
			cin >> all[i];//每个人住在哪 
			g[i].clear();
		}
		
		for (int i = 0; i < n; i++) {
			cin >> diff[i];//给定的对照值 
		}
		
		for (int i=0;i<n-1;i++){//建图 
			int a, b;
			cin>>a>>b;
			a--;
			b--;
			g[a].push_back(b);
			g[b].push_back(a);
		}
		dfs(0, -1);
		if(f) cout << "YES"<<endl;
		else cout << "NO" <<endl;
	}
	return 0; 
}

D 不太理解,队友做了

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档