比赛链接:https://codeforc.es/contest/1385 pro:3.5 / 7 =====A===== *题意:多组数据,每组三个正整数$x, y, z$,构造$a, b, c$满足$x = max(a, b)$, $y = max(a, c)$, $z= max(b, c)$ *题解:签到题,分类特判即可 #include using namespace std; typedef long long ll; const int maxn = 2e5 + 5; const double pi = acos(-1); const int mod = 998244353; int x, y, z, a, b, c; int t; int main(){ cin >> t; while(t--){ cin >> x >> y >> z; int a = (x == y) + (x == z) + (y == z); if(!a){ puts("NO"); continue; } else if(a == 3){ puts("YES"); cout << x << ' ' << x << ' ' << x << endl; continue; } else{ if((x == y && z > x) || (x == z && y > x) || (y == z && x > y)) puts("NO"); else{ puts("YES"); if(x == y) cout << x << ' ' << z << ' ' << z << endl; else if(x == z) cout << x << ' ' << y << ' ' << y << endl; else cout << y << ' ' << x << ' ' << x << endl; } } } } =====B===== *题意:给定多组有且仅有两次重复的数字序列,在不影响相对顺序的前提下去重 *题解:签到题,打标记跳输出即可 #include using namespace std; typedef long long ll; const int maxn = 2e5 + 5; const double pi = acos(-1); const int mod = 998244353; int t; int n; int a[105]; int main(){ cin >> t; while(t--){ cin >> n; int tmp; memset(a, 0, sizeof(a)); for(int i = 1; i <= 2 * n; ++i){ cin >> tmp; if(a[tmp]) continue; cout << tmp << ' '; a[tmp] = 1; } puts(""); } } =====C===== *题意:定义“good”序列:每次从首位或末位拿出元素,组成的新序列单调不降。多组数据,给定序列,询问删去从首位开始的至少多少元素,可以使序列成为“good”序列? *题解:所谓“good”序列就是从首末开始到某一位置都单调不降的序列,只需倒序遍历,先找不降序列,由此后找不升序列,统计剩余元素个数输出即可 #include using namespace std; typedef long long ll; const int maxn = 2e5 + 5; const double pi = acos(-1); const int mod = 998244353; int t; int n; int a[maxn]; int main(){ cin >> t; while(t--){ cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i]; if(n == 1){ cout << 0 << endl; continue; } int p = -1, q = -1; for(int i = n; i > 1; --i){ if(a[i-1] < a[i]){ p = i; break; } } if(p == -1){ cout << 0 << endl; continue; } for(int i = p; i > 1; --i){ if(a[i-1] > a[i]){ q = i; break; } } if(q == -1) cout << 0 << endl; else cout << q - 1 << endl; } } =====D===== *见本周推荐