Skip to content

泉州一中信息学Blog

信息学奥赛技术分享博客

  • 登录
  • 小学oj
  • 中学oj
  • 测试页面1
  • Toggle search form

南外集训 Day 3

Posted on 2023年8月3日 By 王, 柏铮

The third day of intensive training at Nanjing Foreign Language School.
今天打比赛,第一题水题
第二题思路没错,但打的时候代码有问题

#include <bits/stdc++.h>
using namespace std;
int T, l, r;
void work() {
    int res = INT_MAX, tot = 0;
    cin >> l >> r;
    int d = 1;
    for (int i = l; i <= r; i = i + d) {
        int k = i, dis = 1, ans = 0;
        while (k % 10 == 0) {
            k = k / 10;
            dis *= 10;
        }
        int h = k % 10, c = 0;
        while (k) {
            c++;
            k = k / 10;
        }
        if (h == 5) {
            ans = c * 2 - 1;
        } else {
            ans = c * 2;
        }
        if (res > ans) {
            tot = i;
            res = ans;
        }
        d = dis;
    }
    cout << tot << endl;
}
int main() {
    cin >> T;
    while (T) {
        work();
        T--;
    }
    return 0;
}

第三题手写队列,但是有个部分的思路错误

#include <bits/stdc++.h>
using namespace std;
int m, k, p, head, tail, all, a[52000];
string s;
int main() {
    cin >> m >> k >> p;
    cin >> s;
    int len = s.size();
    tail = k - 1;
    while (tail < len) {
        int q = 0;
        for (int i = head; i <= tail; i++) {
            if (s[i] == &#039;Q&#039;) {
                q++;
            }
        }
        if (q >= p) {
            for (int i = head; i <= tail; i++) {
                a[i]++;
            }
            all++;
        }
        head++;
        tail++;
    }
    int x = all - m + 1;
    for (int i = 0; i < len; i++) {
        if (a[i] == 0) {
            cout << "-";
        } else if (a[i] >= x) {
            cout << "+";
        } else {
            cout << "?";
        }
    }
    return 0;
}

第四题用背包,改良后却还是错,打题的思路有问题

#include <bits/stdc++.h>
using namespace std;
struct EEE {
    int w, v;
} a[10000];
int dp[10050][5];
int n, l;
int main() {
    cin >> n >> l;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].v >> a[i].w;
    }
    int ans = -1;
    for (int i = 1; i <= n; i++) {
        int c;
        ans = max(ans, a[i].w);
        if (a[i].v % 2 == 0)
            c = a[i].v / 2;
        else
            c = a[i].v / 2 + 1;
        for (int j = l; j >= c; j--) {
            for (int t = 2; t >= 0; t--) {
                if (t >= 1) {
                    dp[j][t] = max(dp[j][t], dp[j - c][t - 1] + a[i].w);
                }
                if (j >= a[i].v) {
                    dp[j][t] = max(dp[j][t], dp[j - a[i].v][t] + a[i].w);
                }
            }
        }
    }
    for (int i = 1; i <= l; i++) {
        for (int j = 0; j <= 2; j++) {
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans;
    return 0;
}
训练日志

文章导航

Previous Post: 南京3-3
Next Post: 常州Day0
2025年 6月
一 二 三 四 五 六 日
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« 2月    

2024常州 Class Classic OI Problems Contest cqr的长乐集训2023 CZYZ LOC New Game NOI NOIP Password Protected PM_PK Preview Problems Retrospect Selfmade Qusetion STL The end Training Uneasy Problem 蒟蒻 通报

  • 训练日志
  • 链表
  • 入门
  • 模拟
  • dfs序
  • 并查集
  • spfa
  • 最小割
  • 矩阵树定理
  • 仙人掌
  • BSGS
  • 凸包
  • 回文自动机
  • 递推与动归
  • 堆
  • 莫队算法
  • ST表
  • Treap
  • 树套树
  • 可持久化线段树
  • 初赛
  • 搜索
  • 贪心
  • 深度优先搜索
  • 欧拉图
  • dijkstra
  • 费用流
  • 哈夫曼树
  • kruskual
  • 置换
  • 旋转卡壳
  • KMP
  • 区间动归
  • STL
  • 链表
  • 可并堆
  • sply
  • 主席树
  • 可持久化字典树
  • 算法
  • 动态规划
  • 构造
  • 广度优先搜索
  • 最短路
  • floyd
  • 最大流
  • 虚树
  • prim
  • 筛法
  • 半平面交
  • 字典树
  • 背包动归
  • 基础数据结构
  • 分块
  • 线段树
  • 替罪羊树
  • K-DTree
  • 图论
  • 二分法
  • 迭代搜索
  • 拓扑排序
  • 有上下界网络流
  • 生成树
  • 快速幂
  • 后缀数组
  • 树形动归
  • 哈希表
  • 中级数据结构
  • 平衡树
  • 可持久化数据结构
  • 数据结构
  • 三分法
  • 启发式搜索
  • 图的连通
  • 点分治
  • 博弈论
  • AC自动机
  • 状压动归
  • 单调栈
  • 树状数组
  • 高级数据结构
  • OI资料
  • 数学
  • 高精度
  • 差分约束
  • 树上倍增
  • 素数测试
  • 后缀自动机
  • 数位动归
  • 单调队列
  • 新闻
  • 几何
  • 随机化
  • 二分图染色
  • 树链剖分
  • 欧拉函数
  • manacher
  • 斜率优化
  • 离线处理
  • 信息学奥赛学长风采
  • 字符串
  • 二分图匹配
  • prufer编码
  • 卡特兰数
  • 密码学
  • 决策单调
  • 赛后总结
  • 其他
  • 2-SAT
  • 最近公共祖先
  • 矩阵乘法
  • 记忆化搜索
  • 网络流
  • Link cut tree
  • 排列组合
  • 树
  • 高斯消元
  • 乘法逆元
  • 容斥原理
  • 调和级数
  • 概率与期望
  • 模线性方程组
  • 莫比乌斯反演
  • 快速傅里叶变换
  • 扩展欧几里德
  • 最大公约数与最小公倍数

近期文章

  • DP杂题
  • 2025年2月13日模拟赛
  • HLOJ-TEST ROUND 4-T1/T2(构造)- 3
  • HLOJ-TEST ROUND 4-T1/T2(构造)- 2
  • HLOJ-TEST ROUND 4-T1/T2(构造)- 1

近期评论

归档

  • 2025年2月
  • 2025年1月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月

Copyright © 2025 泉州一中信息学Blog.

Powered by PressBook WordPress theme