题号 | 标题 | 已通过代码 | 题解/讨论 | 通过率 | 团队的状态 |
---|---|---|---|---|---|
A | Garbage Classification | 点击查看 | 进入讨论 | 1036/1650 | |
B | Shorten IPv6 Address | 点击查看 | 进入讨论 | 804/5504 | |
C | Palindrome Mouse | 点击查看 | 进入讨论 | 175/467 | |
D | Move | 点击查看 | 进入讨论 | 943/5467 | |
E | Androgynos | 点击查看 | 进入讨论 | 263/1029 | 补题通过 |
F | K-ary Heap | 点击查看 | 进入讨论 | 33/100 | 未通过 |
G | Is Today Friday? | 点击查看 | 进入讨论 | 465/2276 | 补题通过 |
H | Train Driver | 点击查看 | 进入讨论 | 74/284 | 未通过 |
I | Can They Go to Galar? | 点击查看 | 进入讨论 | 29/134 | 未通过 |
J | Upgrading Technology | 点击查看 | 进入讨论 | 926/5235 |
ps:这场只做了C题,第一次场上做出来这种题,虽然花时间久了点。其他都队友做的orz
A
#include <bits/stdc++.h>
using namespace std;
int T;
char a[10005];
char b[30];
int kase = 0;
int main(){
scanf("%d", &T);
while(T--){
scanf("%s%s", a, b);
int h, d, w;
d = w = h = 0;
int n = 0;
for(int i = 0; a[i]; i++){
if(b[a[i] - 'a'] == 'h'){
h++;
}
else if(b[a[i] - 'a'] == 'w'){
w++;
}
else if(b[a[i] - 'a'] == 'd'){
d++;
}
n++;
}
kase++;
printf("Case #%d: ", kase);
double p = double(h) / double(n);
if(p >= 0.25){
printf("Harmful
");
}
else if(p <= 0.1){
printf("Recyclable
");
}
else if(d >= 2 * w){
printf("Dry
");
}
else{
printf("Wet
");
}
}
return 0;
}
B
#include <bits/stdc++.h>
using namespace std;
int T;
char a[10005];
int kase = 0;
int b[50];
string c[10];
vector<string> ans;
int min_l;
char change(int a){
if(a < 10){
return a + '0';
}
else{
return a - 10 + 'a';
}
}
bool allzero(int l, int r){
if(l > 0 && c[l - 1] == string("0")){
return false;
}
if(r < 7 && c[r + 1] == string("0")){
return false;
}
for(int i = l; i <= r; i++){
if(c[i] != string("0")){
return false;
}
}
return true;
}
string solve_pre(){
string p = string("");
for(int i = 0; i < 8; i++){
if(i != 0) p += ':';
p += c[i];
}
min_l = min(min_l, int(p.length()));
return p;
}
void solve(int l, int r){
string p = string("");
for(int i = 0; i < l; i++){
if(i != 0) p += ':';
p += c[i];
}
p += "::";
for(int i = r + 1; i < 8; i++){
if(i != r + 1) p += ':';
p += c[i];
}
min_l = min(min_l, int(p.length()));
ans.push_back(p);
}
int main(){
scanf("%d", &T);
while(T--){
min_l = 10000;
// 输入和初始化
scanf("%s", a);
memset(b, 0, sizeof(b));
for(int i = 0; i < 10; i++){
c[i] = string("");
}
ans.clear();
// 四位转换成一个十六进制数
int t = 0;
int cnt = 0;
for(int i = 0; i < 128; i++){
if((i) && (i % 4 == 0)){
b[cnt] = t;
cnt++;
t = 0;
}
t *= 2;
t |= (a[i] - '0');
}
b[cnt] = t;
// 四位十六进制合成一个字符串
cnt = 0;
string ts = string("");
for(int i = 0; i < 32; i++){
if(i && (i % 4 == 0)){
if(ts == string("")){
ts = string("0");
}
c[cnt] = ts;
cnt++;
ts = string("");
}
if(ts == string("") && b[i] == 0){
continue;
}
else{
ts = ts + change(b[i]);
}
}
if(ts == string("")){
ts = string("0");
}
c[cnt] = ts;
cnt = 0;
ans.push_back(solve_pre());
for(int i = 0; i < 8; i++){
for(int j = i + 1; j < 8; j++){
if(allzero(i, j)){
// cout << "lalala" << endl;
solve(i, j);
}
}
}
kase++;
printf("Case #%d: ", kase);
sort(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i++){
if(ans[i].length() == min_l){
cout << ans[i] << endl;
break;
}
}
/*
for(int i = 0; i < ans.size(); i++){
cout << ans[i] << endl;
}
*/
}
return 0;
}
C
写了篇题解:https://www.cnblogs.com/1625--H/p/11296121.html
D
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[1005];
bool check(int v) {
bool vis[1005];
memset(vis, 0, sizeof(bool) * (n + 2));
int cn = 0;
int cnt = 0;
while(1) {
int las = v;
if(cn > k) break;
for(int i = n; i >= 1; i--) {
if(vis[i]) continue;
if(a[i] <= las) {
vis[i] = 1;
las -= a[i];
cnt++;
if(cnt == n) break;
}
}
cn++;
if(cnt == n) break;
}
if(cnt < n || cn > k) return false;
return true;
}
int main() {
int T;
scanf("%d", &T);
int cas = 0;
while(T--) {
cas++;
scanf("%d%d", &n, &k);
int l = 1, r = 0;
for(int i = 1; i <= n; i++) scanf("%d", &a[i]), r += a[i];
sort(a + 1, a + 1 + n);
l = a[n];
int mid = l + r >> 1;
while(l + 1 < r) {
mid = l + r >> 1;
if(check(mid)) r = mid;
else l = mid;
}
int ans = 0;
printf("Case #%d: ", cas);
if(check(l)) ans = l;
else ans = r;
for(int i = l; i >= max(a[n], l - 100); i--) {
if(check(i)) ans = i;
}
printf("%d
", ans);
}
return 0;
}
E
#include <bits/stdc++.h>
using namespace std;
int tu[2005][2005];
int f[2005];
int main() {
int T;
scanf("%d", &T);
int cas = 0;
while(T--) {
int n;
scanf("%d", &n);
int tmp = n % 4;
printf("Case #%d: ", ++cas);
if(tmp == 2 || tmp == 3) {
puts("No");
continue;
} else puts("Yes");
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++) tu[i][j] = 0;
for(int i = 1; i <= n; i++) f[i] = -1;
int blo = n / 4;
for(int i = 1; i <= blo * 4; i++) {
if(i <= blo) {
for(int j = 1; j <= blo; j++) {
if(i == j) continue;
tu[i][j] = tu[j][i] = 1;
}
for(int j = blo + 1; j <= blo * 2; j++) tu[i][j] = tu[j][i] = 1;
for(int j = blo * 2 + 1; j <= blo * 3; j++) tu[i][j] = tu[j][i] = 1;
f[i] = blo * 3 + i;
} else if(i > blo && i <= blo * 2) {
for(int j = blo + 1; j <= blo * 2; j++) {
if(i == j) continue;
tu[i][j] = tu[j][i] = 1;
}
for(int j = blo * 3 + 1; j <= blo * 4; j++) tu[i][j] = tu[j][i] = 1;
f[i] = blo + i;
} else if(i > blo * 2 && i <= blo * 3) f[i] = i - blo * 2;
else f[i] = i - blo * 2;
}
if(n % 4 == 1) {
f[n] = n;
for(int i = blo * 2 + 1; i <= blo * 4; i++) tu[n][i] = tu[i][n] = 1;
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) printf("%d", tu[i][j]);
puts("");
}
for(int i = 1; i <= n; i++) {
if(i != n) printf("%d ", f[i]);
else printf("%d
", f[i]);
}
}
return 0;
}
G
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
bool f, ff;
char ss[15];
int s[100005][15];
int n, cnt;
int dp[10005][15][45];
bool caile(int y, int m, int d) {
if(m <= 2) m += 12, y -= 1;
int c = y / 100;
y = y - c * 100;
int w = y + y / 4 + c / 4 - 2 * c + 26 * (m + 1) / 10 + d - 1;
w %= 7;
w = (w + 7) % 7;
if(w == 5) return true;
return false;
}
int l[15], r[15];
int vis[15], to[15];
void dfs(int pos) {
if(pos > 9) {
for(int i = 1; i <= cnt; i++) {
int y = 0, m = 0, d = 0;
for(int j = 1; j <= 4; j++) y = y * 10 + to[s[i][j]];
for(int j = 5; j <= 6; j++) m = m * 10 + to[s[i][j]];
for(int j = 7; j <= 8; j++) d = d * 10 + to[s[i][j]];
if(y < 1600 || y > 9999 || m > 12 || d > 35) return;
if(dp[y][m][d] != 5) return;
}
ff = true;
return;
}
for(int i = l[pos]; i <= r[pos]; i++) {
if(vis[i] == -1) {
vis[i] = pos, to[pos] = i;
dfs(pos + 1);
if(ff) return;
vis[i] = -1, to[pos] = -1;
}
}
}
int mm[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
memset(dp, -1, sizeof(dp));
int now = 0;
for(int i = 1600; i <= 9999; i++) {
for(int j = 1; j <= 12; j++) {
int dd = mm[j];
if(j == 2)
if(i % 400 == 0 || ((i % 100 != 0) && (i % 4 == 0))) dd++;
for(int k = 1; k <= dd; k++) {
dp[i][j][k] = now;
now++; now %= 7;
}
}
}
for(int i = 1600; i <= 9999; i++) {
for(int j = 1; j <= 12; j++) {
for(int k = 1; k <=35; k++) {
if(dp[i][j][k] != -1) {
dp[i][j][k] = (dp[i][j][k] - 1 + 7) % 7;
}
}
}
}
int T;
scanf("%d", &T);
int cas = 0;
while(T--) {
cnt = 0;
ff = false;
f = false;
mp.clear();
memset(vis, -1, sizeof(vis));
scanf("%d", &n);
for(int i = 0; i <= 9; i++) l[i] = 0, r[i] = 9;
for(int i = 1; i <= n; i++) {
scanf("%s", ss + 1);
int now = 0;
now = now * 10 + (ss[1] - 'A');
now = now * 10 + (ss[2] - 'A');
now = now * 10 + (ss[3] - 'A');
now = now * 10 + (ss[4] - 'A');
now = now * 10 + (ss[6] - 'A');
now = now * 10 + (ss[7] - 'A');
now = now * 10 + (ss[9] - 'A');
now = now * 10 + (ss[10] - 'A');
if(mp[now]) continue;
mp[now] = 1;
s[++cnt][1] = ss[1] - 'A';
s[cnt][2] = ss[2] - 'A';
s[cnt][3] = ss[3] - 'A';
s[cnt][4] = ss[4] - 'A';
s[cnt][5] = ss[6] - 'A';
s[cnt][6] = ss[7] - 'A';
s[cnt][7] = ss[9] - 'A';
s[cnt][8] = ss[10] - 'A';
int t1 = ss[1] - 'A';
l[t1] = max(l[t1], 1);
int t2 = ss[6] - 'A';
r[t2] = min(r[t2], 1);
int t3 = ss[9] - 'A';
r[t3] = min(r[t3], 3);
}
dfs(0);
/*
if(ff) {
f = true;
for(int i = 1; i <= cnt; i++) {
int y = 0, m = 0, d = 0;
for(int j = 1; j <= 4; j++) y = y * 10 + to[s[i][j]];
for(int j = 5; j <= 6; j++) m = m * 10 + to[s[i][j]];
for(int j = 7; j <= 8; j++) d = d * 10 + to[s[i][j]];
if(y < 1600 || y > 9999 || m > 12 || d > 31) {
f = false;
break;
}
if(!caile(y, m, d)) {
f = false;
break;
}
}
}*/
printf("Case #%d: ", ++cas);
if(ff) {
for(int i = 0; i < 10; i++) printf("%d", to[i]);
puts("");
} else puts("Impossible");
}
return 0;
}
J
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
int c[1005][1005];
int d[1005];
ll sum[1005][1005];
int mb[1005][1005];
int main() {
int T;
int cas = 0;
scanf("%d", &T);
while(T--) {
cas++;
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++) {
sum[i][0] = 0;
for(int j = 1; j <= m; j++) {
scanf("%d", &c[i][j]);
sum[i][j] = sum[i][j - 1] + 1LL * c[i][j];
}
mb[i][m] = m;
for(int j = m - 1; j >= 0; j--) {
if(sum[i][j] > sum[i][mb[i][j + 1]])
mb[i][j] = mb[i][j + 1];
else mb[i][j] = j;
}
}
d[0] = 0;
ll ans = 0;
ll ssum = 0;
ll tmp = 0;
for(int i = 1; i <= m; i++) scanf("%d", &d[i]);
for(int j = 0; j <= m; j++) {
tmp += 1LL * d[j];
ssum = 0;
int cn = 0;
ll zx = 1e13;
for(int i = 1; i <= n; i++) {
int t = mb[i][j];
ssum += sum[i][t];
if(t > j) {
cn++;
zx = min(zx, sum[i][j] - sum[i][t]);
}
}
if(cn == n) ans = max(ans, tmp - ssum - zx);
else ans = max(ans, tmp - ssum);
}
printf("Case #%d: ", cas);
printf("%lld
", ans);
}
return 0;
}