Mu_shao
2024-10-28 19:28:35
签到题不多说。
#include<bits/stdc++.h>
using namespace std;
int n, ans = 52;
map<string, int> mp;
int main() {
freopen("poker.in", "r", stdin);
freopen("poker.out", "w", stdout);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
if (mp[s]) continue;
mp[s] = 1;
ans--;
}
printf("%d", ans);
return 0;
}
没啥特殊的,依据题意打即可。
#include<bits/stdc++.h>
using namespace std;
int T, n, m, k, ans;
int sx, sy, sd;
int mp[1010][1010], vis[1010][1010];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
void dfs(int x, int y, int d) {
k--;
if (!vis[x][y]) ans++;
vis[x][y] = 1;
if (!k) return ;
int xx = x+dx[d], yy = y+dy[d];
while (xx<1 || xx>n || yy<1 || yy>m || mp[xx][yy]) {
k--;
if (!k) break;
d = (d+1)%4;
xx = x+dx[d], yy = y+dy[d];
}
if (!k) return ;
dfs(xx, yy, d);
}
int main() {
freopen("explore.in", "r", stdin);
freopen("explore.out", "w", stdout);
scanf("%d", &T);
while (T--) {
ans = 0;
memset(vis, 0, sizeof(vis));
scanf("%d%d%d", &n, &m, &k);
scanf("%d%d%d", &sx, &sy, &sd);
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
for (int j = 0; j < m; j++) {
if (s[j] == '.') mp[i][j+1] = 0;
else mp[i][j+1] = 1;
}
}
k += 1;
dfs(sx, sy, sd);
printf("%d\n", ans);
}
return 0;
}
暴力,但是官方数据测试没有 生气 神奇,期望是能拿到更多分数,并没有想出规律,白白丢失
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7;
int num[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
ll dp[maxn], vis[maxn];
int T, n;
int main() {
freopen("sticks.in", "r", stdin);
freopen("sticks.out", "w", stdout);
scanf("%d", &T);
for (ll i = 1; i <= maxn; i++) dp[i] = maxn;
for (ll i = 0; i <= maxn; i++) {
ll x = i, cnt = 0;
while (x) {
cnt += num[x%10];
x /= 10;
}
dp[cnt] = min(dp[cnt], i);
vis[cnt]++;
}
while (T--) {
scanf("%d", &n);
if (!vis[n]) printf("-1\n");
else printf("%lld\n", dp[n]);
}
return 0;
}
不服啊,有想法不知道怎么实现。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int T, n, k, q;
int l, s[maxn<<2];
map<pair<int, int>, int> mp;
int main() {
freopen("chain.in", "r", stdin);
freopen("chain.out", "w", stdout);
scanf("%d", &T);
while (T--) {
scanf("%d%d%d", &n, &k, &q);
for (int i = 1; i <= n; i++) {
scanf("%d", &l);
for (int j = 1; j <= l; j++) scanf("%d", &s[j]);
for (int j = l; j >= 1; j--) {
for (int o = max(j-k+1, 1); o < j; o++)
mp[make_pair(s[o], s[j])] = 1;
}
}
for (int i = 1; i <= q; i++) {
int r, c;
scanf("%d%d", &r, &c);
if (mp[make_pair(1, c)]) printf("1\n");
else printf("0\n");
}
}
return 0;
}
考场上没看出来是众数 (看出来也不敢打) ,使用的是各个数值和出现次数,按照从小到大顺序比对做减法,可证明是最优解。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int n, a[maxn], b[maxn];
int num[maxn], cnt, ans;
int tr[maxn];
int main() {
freopen("duel.in", "r", stdin);
freopen("duel.out", "w", stdout);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
b[a[i]]++; tr[a[i]]++;
}
sort(a+1, a+1+n);
for (int i = 1; i <= n; i++) {
if (a[i] != a[i-1]) num[++cnt] = a[i];
}
for (int i = 1; i < cnt; i++) {
int j = i+1;
while (b[num[i]] && j <= cnt) {
if (!tr[num[j]]) {
j++;
continue;
}
if (b[num[i]] >= tr[num[j]]) {
b[num[i]] -= tr[num[j]];
tr[num[i]] -= b[num[j]];
tr[num[j]] = 0;
} else {
tr[num[j]] -= b[num[i]];
b[num[i]] = 0;
}
j++;
}
}
for (int i = 1; i <= cnt; i++) ans += b[num[i]];
printf("%d", ans);
return 0;
}
我称之曰
分体式打法!!
分别三个代码打出
再往后,我看到一句明晃晃的标语。
前面的区域,以后再来探索吧!
简称就是没看懂或不会做,爽爽的睡了一个小时,哈哈哈哈哈......
(假的,一直在磕,脑袋都要坏掉了。 )
总的来说觉得还行,比前几年舒服很多,也还有需要进步的地方,但是就考场的反应和态度来说我认为挺不错的了,总之,秉持一句话: 遇到困难睡大觉
其实是 有志者事竟成!,下次继续战斗!