A
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
//constexpr int M = 998244353;
//constexpr int M = 1000000007;
bool no[10];
int cnt[10];
void solve() {
string s, t;
cin >> s >> t;
string S = {s[0], s[1], s[3], s[4], s[6], s[7]},
T = {t[0], t[1], t[3], t[4], t[6], t[7]};
for (int i = 0; i < 6; i++) {
if (T[i] == 'B') {
no[S[i] - '0'] = 1;
}
if (T[i] == 'P') {
cnt[S[i] - '0']++;
}
}
vector<array<int, 6>> ans;
auto check = [&](int A, int B, int C, int D, int E, int F) {
if (A * 10 + B + C * 10 + D != E * 10 + F) {
return false;
}
int CNT[10] = {0};
vector<int> a{A, B, C, D, E, F};
for (int i = 0; i < 6; i++) {
if (T[i] == 'G') {
if (a[i] != S[i] - '0') {
return false;
}
} else if (T[i] == 'P') {
if (a[i] == S[i] - '0') {
return false;
}
} else {
if (a[i] == S[i] - '0') {
return false;
}
}
}
for (int i = 0; i < 6; i++) {
if (T[i] != 'G') {
CNT[a[i]]++;
}
}
for (int i = 0; i < 10; i++) {
if (no[i] && CNT[i] != cnt[i]) {
return false;
}
if (!no[i] && CNT[i] < cnt[i]) {
return false;
}
}
return true;
};
for (int A = 0; A <= 9; A++) {
for (int B = 0; B <= 9; B++) {
for (int C = 0; C <= 9; C++) {
for (int D = 0; D <= 9; D++) {
for (int E = 0; E <= 9; E++) {
for (int F = 0; F <= 9; F++) {
if (check(A, B, C, D, E, F)) {
ans.push_back({A, B, C, D, E, F});
}
}
}
}
}
}
}
int asz = ans.size();
cout << asz << '\n';
for (int i = 0; i < asz; i++) {
auto [A, B, C, D, E, F] = ans[i];
cout << A << B << "+" << C << D << "=" << E << F << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed << setprecision(6);
int tt = 1;
//cin >> tt;
for (int _ = 1; _ <= tt; _++) {
solve();
}
return 0;
}
G
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
//constexpr int M = 998244353;
//constexpr int M = 1000000007;
void solve() {
double b, r, d, s;
cin >> b >> r >> d >> s;
if (r == 0) {
if (d != 0) {
cout << "gua!" << '\n';
return;
}
}
double relcnt = (int) (r * s / 60.0) + 1;
double relsum = relcnt * b;
if (relsum < d) {
cout << "gua!" << '\n';
} else {
cout << "ok" << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed << setprecision(6);
int tt = 1;
cin >> tt;
for (int _ = 1; _ <= tt; _++) {
solve();
}
return 0;
}
M
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
//constexpr int M = 998244353;
//constexpr int M = 1000000007;
constexpr int N = 5E5;
bool vis[N + 1];
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> a(m, vector<int>(n));
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
int cnt = 0;
int last = 0;
vector<int> st;
vector<int> ans(n + 1);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (!vis[a[j][i]]) {
cnt++;
vis[a[j][i]] = 1;
st.push_back(a[j][i]);
}
}
if (cnt == i + 1) {
while (!st.empty()) {
ans[st.back()] = n - last - 1;
st.pop_back();
}
last = i + 1;
}
}
for (int i = 1; i <= n; i++) {
cout << ans[i] << " \n"[i == n];
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed << setprecision(6);
int tt = 1;
//cin >> tt;
for (int _ = 1; _ <= tt; _++) {
solve();
}
return 0;
}
标签:10,cnt,return,constexpr,int,上海,++,2022,省赛
From: https://www.cnblogs.com/kiddingma/p/16767276.html