# Educational Codeforces Round 143 (Rated for Div. 2)(vp)

22 篇文章 0 订阅

A. Two Towers

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
ios::sync_with_stdio(false), cin.tie(nullptr);
int N;
cin >> N;
while (N--){
int n, m;
string a, b;
cin >> n >> m >> a >> b;
int tag = 0, len = 1, cnt = 0;
a = a + string(b.rbegin(), b.rend());
for (int i = 1; i < a.size(); ++i){
if (a[i] == a[i - 1]) len += 1;
else len = 1;
if (len == 2){cnt += 1;}
if (cnt > 1 || len == 3) {tag = 1; break;}
}
cout << (tag == 0 ? "YES" : "NO") << endl;
}
return 0;
}



B. Ideal Point

#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
ios::sync_with_stdio(false), cin.tie(nullptr);
int N;
cin >> N;
while (N--){
int n, k;
cin >> n >> k;
vector<vector<int>> a(n, vector<int> (2));
map<int, int> mapp;
for (int i = 0; i < n; ++i){
cin >> a[i][0] >> a[i][1];
if (a[i][0] <= k && k <= a[i][1]){
int R = a[i][1], L = a[i][0];
while (L <= R){mapp[L] += 1; L += 1;}
}
}
int tag = 0;
for(auto x : mapp){
if ((x.second >= mapp[k] && x.first != k)) { tag = 1; break;}
}
if (mapp[k] == 0) tag = 1;
cout << (tag == 0 ? "YES\n" : "NO\n");
}
return 0;
}



C. Tea Tasting

#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
ios::sync_with_stdio(false), cin.tie(nullptr);
int N;
cin >> N;
while (N--){
int n;
cin >> n;
vector<long long int> a(n + 1), b(n + 1), r(n + 1, 0), s(n + 1, 0), d(n + 1, 0);
for (int i = 1; i <= n; ++i){
cin >> a[i];
}
for (int i = 1; i <= n; ++i){
cin >> b[i];
s[i] += s[i - 1] + b[i];
}
for (int i = 1; i <= n; ++i){
int k = i - 1, p = 1, sum = 0;
while(p){
if (k + p > n) {p /= 2; continue;}
if (sum + s[k + p] - s[k] <= a[i]){
sum += s[k + p] - s[k];
k += p;
p *= 2;
}
else{
p /= 2;
}
}
d[i] += 1;
if (k < n) d[k + 1] -= 1;
if (a[i] - sum > 0 && k < n) r[k + 1] += min(a[i] - sum, b[k + 1]);
}
for (int i = 1; i <= n; ++i){
d[i] += d[i - 1];
cout << r[i] + d[i] * b[i] << " \n"[i == n];
}
}
return 0;
}



• 0
点赞
• 0
收藏
觉得还不错? 一键收藏
• 0
评论
04-26 471
02-21 487
01-28 738
03-06 234
02-17 407
07-06 531
06-12 236

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

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