#include <bits/stdc++.h>
using namespace std;
int main() {
int l, h, a, b;
cin >> l >> h >> a >> b;
if(a >= l && b >= l) {
cout << a << "-Y " << b << "-Y\n";
cout << "huan ying ru guan";
} else if(min(a, b) < l && max(a, b) >= h) {
cout << a << "-Y " << b << "-Y\n";
int x, y;
if(a > b) x = 1, y = 2;
else x = 2, y = 1;
printf("qing %d zhao gu hao %d\n", x, y);
} else if(a < l && b < l) {
cout << a << "-N " << b << "-N\n";
cout << "zhang da zai lai ba";
} else if(a < l && b >= l && b < h) {
cout << a << "-N " << b << "-Y\n";
cout << "2: huan ying ru guan";
} else if(a >= l && a < h && b < l) {
cout << a << "-Y " << b << "-N\n";
cout << "1: huan ying ru guan";
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y; cin >> x >> y;
x += y;
long long ans = 1;
for(int i = 1; i <= x; i ++ ) ans *= i;
cout << ans;
return 0;
}
-----
```cpp
#include <bits/stdc++.h>
using namespace std;
bool vis[10][10];
int main() {
vector<int> a(6);
for(int i = 0; i < 6; i ++ ) {
cin >> a[i];
vis[i][a[i]] = true;
}
int x; cin >> x;
for(int i = 1; i <= x; i ++ ) {
for(int j = 0; j < 6; j ++ ) {
// debug(j);
for(int k = 6; k >= 1; k -- ) {
if(!vis[j][k]) {
vis[j][k] = true;
a[i] = k;
break;
}
}
cout << a[i] << " \n"[j == 5];
}
}
for(int i = 0; i < 6; i ++ ) {
cout << a[i] << " \n"[i == 5];
}
return 0;
}
#include <bits/stdc++.h>
#include <debugger>
using namespace std;
bool vis[10][10];
int main() {
string a, b; cin >> a >> b;
string s1, s2;
int n = a.size();
for(int i = 1; i < n; i ++ ) {
if(a[i] % 2 == a[i - 1] % 2) {
s1 += max(a[i], a[i - 1]);
}
}
n = b.size();
for(int i = 1; i < n; i ++ ) {
if(b[i] % 2 == b[i - 1] % 2) {
s2 += max(b[i], b[i - 1]);
}
}
if(s1 == s2) {
cout << s1 << "\n";
} else {
cout << s1 << "\n" << s2 << "\n";
}
}
#include <bits/stdc++.h>
#include <debugger>
using namespace std;
int main() {
int n, m, q; cin >> n >> m >> q;
vector<bool> h(n), l(m);
while(q -- ) {
int op, x;
cin >> op >> x;
if(!op) {
h[x - 1] = true;
} else {
l[x - 1] = true;
}
}
int ans = 0;
for(int i = 0; i < n; i ++ ) {
for(int j = 0; j < n; j ++ ) if(!h[i] && !l[j]) {
ans ++;
}
}
cout << ans << "\n";
}
#include <bits/stdc++.h>
#include <debugger>
using namespace std;
int main() {
int n, k, s;
cin >> n >> k >> s;
vector<int> cnt1(300);
vector<int> cnt2(300);
for(int i = 0; i < n; i ++ ) {
int x, y; cin >> x >> y;
if(y >= s) cnt1[x] ++;
else cnt2[x] ++;
}
int ans = 0;
for(int i = 175; i <= 290; i ++ ) {
ans += min(cnt2[i], k);
ans += cnt1[i];
}
cout << ans << "\n";
}
L2-1
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
struct node {
int ver, d;
bool operator < (const node &T) const {
return d > T.d;
}
}a[3];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k; cin >> n >> m >> k;
vector<vector<int > > ans(n + 1);
vector<int> a(n);
for(int i = 0; i < n; i ++ ) cin >> a[i];
stack<int> stk;
int now = 0;
int id = 0;
for( ; ; ) {
if(ans[now].empty()) {
if(stk.size()) {
ans[now].push_back(stk.top()); stk.pop();
} else {
if(id < n)
ans[now].push_back(a[id ++ ]);
else
break;
}
if((int)ans[now].size() == k) now ++;
} else {
if(!stk.empty() && stk.top() <= ans[now].back()) {
ans[now].push_back(stk.top()); stk.pop();
} else {
while(id < n && a[id] > ans[now].back() && (int) stk.size() < m) {
stk.push(a[id ++]);
// if((int) stk.size() == m) {
// break;
// }
}
if(id == n ) break;
if((int) stk.size() == m && a[id] > ans[now].back()) {
now ++;
continue;
}
ans[now].push_back(a[id ++]);
}
if((int) ans[now].size() == k) now ++;
}
}
// cout << stk.size() << "\n";
for( ; ; ) {
if(stk.empty()) break;
if(ans[now].empty()) {
ans[now].push_back(stk.top()); stk.pop();
continue;
}
if(stk.top() <= ans[now].back()) {
ans[now].push_back(stk.top()); stk.pop();
} else {
now ++;
}
if((int) ans[now].size() == k) now ++;
}
// if(stk.size()) {
// cout << stk.top() << "\n";
// }
for(int i = 0; i < now; i ++ ) {
for(int j = 0; j < (int)ans[i].size(); j ++ ) {
cout << ans[i][j] << " \n"[j == (int)ans[i].size() - 1];
}
}
if(ans[now].size()) {
for(int j = 0; j < (int)ans[now].size(); j ++ ) {
cout << ans[now][j] << " \n"[j == (int)ans[now].size() - 1];
}
}
return 0;
}
L2-2
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n; cin >> n;
vector<array<ll, 2> > s, ans;
while(n -- ) {
int h1, h2, m1, m2, s1, s2; scanf("%d:%d:%d - %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
ll x = 0, y = 0;
x += h1 * 3600 + m1 * 60 + s1;
y += h2 * 3600 + m2 * 60 + s2;
s.push_back({x, y});
}
sort(s.begin(), s.end());
ll now = 0;
for(int i = 0; i < (int)s.size(); i ++ ) {
if(s[i][0] != now) {
ans.push_back({now, s[i][0]});
}
now = s[i][1];
}
if(now != 60 * 60 * 24 - 1) {
ans.push_back({now, 60 * 60 * 24 - 1});
}
for(int i = 0; i < (int)ans.size(); i ++ ) {
ll x = ans[i][0], y = ans[i][1];
printf("%02d:%02d:%02d - %02d:%02d:%02d", x / 3600, x % 3600 / 60, x % 60, y / 3600, y % 3600 / 60, y % 60);
if(i != (int)ans.size() - 1) cout << "\n";
}
return 0;
}
L2-4 (19分)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int inf = 1e18;
struct node {
int ver;
ll d;
bool operator < (const node &T) const {
return d > T.d;
}
};
signed main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
int n; scanf("%lld", &n); //cin >> n;
// vector<vector<int> > g(n + 1, vector<int>(n + 1, inf));
vector<bool> vis(n + 1);
vector<vector<array<int, 2> > > son(n + 1, vector<array<int, 2> > ());
for(int i = 1; i <= n; i ++ ) {
char c; cin >> c; //scanf("%c", &c);
if(c == 'F') vis[i] = true;
// vis[i] = (c == 'F'); // 女性
int k; cin >> k;
while(k -- ) {
int id, dist;
scanf("%lld:%lld", &id, &dist);
son[i].push_back({id, dist});
// g[i][id] = dist;
}
}
// for(int i = 1; i <= n; i ++ ) {
// for(auto [id, dist] : son[i]) {
// cout << id << " " << dist << "\n";
// }
// }
// // vector<vector<int> > d(n + 1, vec tor<int>(n + 1, inf));
vector<int> ans(n + 1);
auto dijk = [&] (int s) {
vector<int> d(n + 1, inf);
vector<bool> st(n + 1, false);
priority_queue<node> q;
q.push({s, 0});
d[s] = 0;
while(q.size()) {
auto t = q.top(); q.pop();
int u = t.ver, dist = t.d;
if(st[u]) continue;
st[u] = true;
for(auto [v, dis] : son[u]) {
if(d[v] > dist + dis) {
d[v] = dist + dis;
q.push({v, d[v]});
}
}
}
// int mx = -1;
for(int i = 1; i <= n; i ++ ) if(d[i] < inf && vis[i] != vis[s]) {
// cout << i << " " << d[i] << "\n";
ans[i] = max(ans[i], d[i]);
}
};
for(int i = 1; i <= n; i ++ ) dijk(i);
int fmi = inf + 1, mmi = inf + 1;
for(int i = 1; i <= n; i ++ ) {
if(!vis[i] && ans[i] > 0)
fmi = min(fmi, ans[i]);
if(vis[i] && ans[i] > 0)
mmi = min(mmi, ans[i]);
}
// cout << fmi << " " << mmi << "\n";
vector<int> f, m;
for(int i = 1; i <= n; i ++ ) {
if(!vis[i] && ans[i] == fmi)
f.push_back(i);
if(vis[i] && ans[i] == mmi)
m.push_back(i);
}
for(int i = 0; i < (int)m.size(); i ++ ) {
cout << m[i] << " \n"[i + 1 == (int)m.size()];
}
for(int i = 0; i < (int)f.size(); i ++ ) {
cout << f[i] << " \n"[i + 1 == (int)f.size()];
}
return 0;
}