前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【第25~28题】40分钟AC掉4道题,但对技术更要有敬畏之心

【第25~28题】40分钟AC掉4道题,但对技术更要有敬畏之心

作者头像
小码匠
发布2023-08-31 14:26:30
1990
发布2023-08-31 14:26:30
举报
文章被收录于专栏:小码匠和老码农

对话

发生在6月27日9点钟的事。

小码匠:你上课期间,我AC掉了4个题,快表扬我。

老码农:不错,看着挺厉害的。

小码匠:就不能来点直接的吗?话里带话, 光看着厉害,是纸老虎吗?

老码农:本来小码匠就很不错,比去年进步多了,去年有些题目竟拿部分分。我看看你AC了哪几道题?

题目

难度

[NOIP2010 提高组] 机器翻译

普及-

[NOIP2011 提高组] 铺地毯

普及-

[NOIP2012 提高组] Vigenère 密码

普及-

[NOIP2013 提高组] 积木大赛

普及-

老码农:原来如此,这么久远的题。

小码匠:你真是的,就不能鼓励我吗?知道你想说,这些题目比较简单。

老码农:还是你最了解我。

老码农:最近两三年提高组的题目明显要难于之前的,水题越来越少,最简单的题目也是普及/提高-

老码农:信竞生越来越多,越来越低龄化,难度也越来越高,对技术要有敬畏之心,要不断的挑战自己。

老码农:通常做10道简单题,不如做一道难题提升的多,简单题只是数量的累计,对于思维提升、码力提升帮助很小。

小码匠:好啰嗦,好啰嗦,这几道题不是你给我安排的吗?特别讨厌你的但是。。。

小码匠:我知道了。。。别说了。。。

【第25题】题目:[NOIP2010 提高组] 机器翻译

题目原文请移步下面的链接

  • https://www.luogu.com.cn/problem/P1540
    • 参考题解:https://www.luogu.com.cn/problem/solution/P1540
  • 标签:模拟队列
  • 难度:普及-

题解

思路
  • 题解大家可移步看这里,很多童鞋写了各种解法
    • https://www.luogu.com.cn/problem/solution/P1540
代码
代码语言:javascript
复制
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

bool a[1003];

void best_coder() {
    int m, n;
    cin >> m >> n;
    queue<int> q;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if(a[x]) {
            continue;
        }
        q.push(x);
        ++ans;
        a[x] = true;
        if(q.size() > m) {
            a[q.front()] = false;
            q.pop();
        }
    }
    cout << ans;
}

void happy_coder() {

}

int main() {
    // 提升cin、cout效率
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // 小码匠
    best_coder();

    // 最优解
    // happy_coder();

    // 返回
    return 0;
}

【第26题】题目:[NOIP2011 提高组] 铺地毯

题目原文请移步下面的链接

  • https://www.luogu.com.cn/problem/P1003
    • 参考题解:https://www.luogu.com.cn/problem/solution/P1003
  • 标签:模拟暴力
  • 难度:普及-

题解

思路
  • 题解大家可移步看这里,很多童鞋写了各种解法
    • https://www.luogu.com.cn/problem/solution/P1003
代码
代码语言:javascript
复制
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

struct edge {
    int a, b, x, y;
};

void best_coder() {
    int n;
    cin >> n;
    vector<edge> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].a >> v[i].b >> v[i].x >> v[i].y;
        v[i].x += v[i].a;
        v[i].y += v[i].b;
    }
    pair<int, int> t;
    cin >> t.first >> t.second;
    int ans = -1;
    for (int i = 0; i < n; ++i) {
        if ((t.first >= v[i].a && t.first <= v[i].x) && (t.second >= v[i].b && t.second <= v[i].y)) {
            ans = i + 1;
        }
    }
    cout << ans;
}

void happy_coder() {

}

int main() {
    // 提升cin、cout效率
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // 小码匠
    best_coder();

    // 最优解
    // happy_coder();

    // 返回
    return 0;
}

【第27题】题目:[NOIP2012 提高组] Vigenère 密码

题目原文请移步下面的链接

  • https://www.luogu.com.cn/problem/P1079
    • 参考题解:https://www.luogu.com.cn/problem/solution/P1079
  • 标签:模拟字符串
  • 难度:普及-

题解

思路
  • 题解大家可移步看这里,很多童鞋写了各种解法
    • https://www.luogu.com.cn/problem/solution/P1079
代码
代码语言:javascript
复制
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

char key (char x, char y) {
    int a, b;
    if (y <= 'Z') {
         a = y - 'A';
    } else {
        a = y - 'a';
    }
    if (x <= 'Z') {
        b = x - 'A';
    } else {
        b = x - 'a';
    }
    return (y <= 'Z' ? 'A' : 'a') + (a + 26 - b) % 26;
}

void best_coder() {
    string a, b;
    cin >> a >> b;
    int c = a.size();
    int d = b.size();
    for (int i = 0; i < d; ++i) {
        cout << key(a[i % c], b[i]);
    }
}

void happy_coder() {

}

int main() {
    // 提升cin、cout效率
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // 小码匠
    best_coder();

    // 最优解
    // happy_coder();

    // 返回
    return 0;
}

【第28题】题目:[NOIP2013 提高组] 积木大赛

题目原文请移步下面的链接

  • https://www.luogu.com.cn/problem/P1969
    • 参考题解:https://www.luogu.com.cn/problem/solution/P1969
  • 标签:模拟字符串
  • 难度:普及-

题解

思路
  • 题解大家可移步看这里,很多童鞋写了各种解法
    • https://www.luogu.com.cn/problem/solution/P1969
代码
代码语言:javascript
复制
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

void best_coder() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    vector<int> a(n);
    int t = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (a[i] > t) {
            ans += a[i] - t;
        }
        t = a[i];
    }
    printf("%d", ans);
}

void happy_coder() {

}

int main() {
    // 提升cin、cout效率
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // 小码匠
    best_coder();

    // 最优解
    // happy_coder();

    // 返回
    return 0;
}

END

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-05-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小码匠和老码农 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 对话
    • 【第25题】题目:[NOIP2010 提高组] 机器翻译
      • 题解
        • 思路
        • 代码
      • 【第26题】题目:[NOIP2011 提高组] 铺地毯
        • 题解
          • 思路
          • 代码
        • 【第27题】题目:[NOIP2012 提高组] Vigenère 密码
          • 题解
            • 思路
            • 代码
          • 【第28题】题目:[NOIP2013 提高组] 积木大赛
            • 题解
              • 思路
              • 代码
          相关产品与服务
          机器翻译
          机器翻译(Tencent Machine Translation,TMT)结合了神经机器翻译和统计机器翻译的优点,从大规模双语语料库自动学习翻译知识,实现从源语言文本到目标语言文本的自动翻译,目前可支持十余种语言的互译。
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档