atcoder abc 243

A

#include
using namespace std;
int main(){
	int a,b,c,v;
	cin>>v>>a>>b>>c;v%=a+b+c;
	if(v-a<0)cout<<"F";
	else if(v-a-b<0)cout<<"M";
	else cout<<"T";
}

B

#include
#include
using namespace std;
int n, a[1001], b, num1, num2;
map<int, int>mp;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i], mp[a[i]]++;
	for (int i = 1; i <= n; i++) {
		cin >> b;
		if(a[i]==b)num1++;
		else if(mp[b] == 1)num2++;
	}
	cout<<num1<<endl<<num2;
}

C

#include
using namespace std;
const int N = 2e5 + 3;
int n;string x;
struct xy {
	int face, x, y;
} t[N];
bool cmp(xy a, xy b) {
	if (a.y != b.y)return a.y < b.y;else return a.x < b.x;
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> t[i].x >> t[i].y;
	cin >> x;
	for (int i = 1; i <= n; i++)if (x[i - 1] == 'L')t[i].face = 1;
	sort(t + 1, t + 1 + n, cmp);
	for (int i = 1; i <= n; i++) {
		while (t[i].y == t[i + 1].y) {
			if (t[i].face == 0 && t[i + 1].face == 1) {
				cout << "Yes";return 0;
			}
			i++;
		}
	}
	cout << "No";
}
/*y相等,同向左或右或反向就no否则yes*/

D

#include
using namespace std;
typedef long long ll;
ll n,x,z;string S;
bool b[1000001];
int main(){
	cin>>n>>x>>S;
	for(int i=0;i<S.size();i++){
		if(S[i]=='L')b[++z]=0;
		if(S[i]=='R')b[++z]=1;
		if(S[i]=='U')
			if(z)z--;else x/=2;
	}
	for(int i=1;i<=z;i++)
		if(b[i])x=x*2+1;else x*=2;
	cout<<x;
}

你可能感兴趣的:(atcoder,abc,c++,c++,算法)