Codeforces Round #575 (Div. 3) A B C

Codeforces Round #575 (Div. 3)

#include
using namespace std;
typedef long long ll;
const int N = 1e5+100;
int n;
ll a,sum=0;
int main(){
	cin >> n;
	while(n--){
		sum=0;
		for(int i=0;i<3;i++){
			cin >> a;
			sum += a;
		}
		cout << sum/2ll << endl;
	}
	return 0;
}

  B

注意最后一个必须输出n

#include
using namespace std;
typedef long long ll;
const int N = 2e5+100;

int q;
int n,k;
int a[N];
int vis[N];
int res[N];
int main(){
	cin >> q;
	while(q--){
		cin >> n >> k;
		memset(vis,0,sizeof(int)*(n+1));
		for(int i=0;i> a[i];
		}
		int flag = 0;
		ll sum =0 ;
		int cnt = 0;
		for(int i=0;i=0;i--){
					if(vis[i]){
						pp++;
						if(vis[n-1])res[pp] = i+1;
						else res[pp] = i;
					}
					if(pp == k) break;
				}
				for(int i=k;i>=1;i--){
					cout << res[i] << (i==1?"\n":" ");
				}
			}
		}
	}
	return 0;
}

  C

根据每个机器人的移动范围,不断缩小所有机器人可达范围

#include
using namespace std;
typedef long long ll;
const int N = 1e5+100;

int q;
int n;
int x[N],y[N];
int f[N][4];
int main(){
	scanf("%d",&q);
	while(q--){
		scanf("%d",&n);
		int r=1e5,l=-1e5,b=1e5,u=-1e5;
		for(int i=1;i<=n;i++){
			scanf("%d%d",&x[i],&y[i]);
			for(int j=0;j<4;j++){
				scanf("%d",&f[i][j]);
			}
			if(f[i][0]==0) l=max(l,x[i]);
			if(f[i][1]==0) b=min(b,y[i]);
			if(f[i][2]==0) r=min(r,x[i]);
			if(f[i][3]==0) u=max(u,y[i]);
		}
		if(l>r||u>b){
			cout << "0\n";
		}
		else{
			cout << "1 " << l << " " << u << endl;
		}
		
		
	}
	return 0;
}

  

转载于:https://www.cnblogs.com/YJing814/p/11244179.html

你可能感兴趣的:(Codeforces Round #575 (Div. 3) A B C)