2023GPLT团体程序设计天梯赛 记录

发布时间 2023-04-22 23:50:36作者: EdwinAze

排名

个人全国排名:  4391(共 1w7)
个人全校排名:  第3
个人 21 级排名:  第2名 (第一名是 ztm 哥, 顶级混分手, 狂砍 181 分)
队伍排名: 河南省  第 23,银牌, 话说为啥去年我会写第九(

分数

得分: 161
题目情况:

L1-01 L1-02 L1-03 L1-04 L1-05 L1-06 L1-07 L1-08 L2-01 L2-02 L2-03 L3-01 L3-02 L3-03
AC AC AC AC AC AC AC AC AC WA3,5 -- WA1,4,6 -- --

共 AC9道满分,L:2-02,L2-03 好像都是 20 分左右, 其实 L2-03 输出 No Solution 也混了 2 分(

经验

都不难, 考前如果你把 PTA 上 L2 的题全刷了至少保底也是 140 分, 就像今年的 L2-01, 永恒不变的考栈, 甚至还没去年 L2-01 插松针一半难。

比拼的还是写代码的熟练度以及快速审题的能力, 就像 L1-06 那个剪贴板题目, 哥们一直以为是粘贴的前缀和后缀之间如果有空位置就替换掉, 且在所有可选位置中找最靠左的, 然而他俩前后缀是连起来的, 本身就是想让你找到前缀后判断后缀是否存在来判断要不要插到最后边。还好样例最后一句 1 1 e r 我没过调了半个多小时才想明白, 不然那真属于是进 ICU 猜谜。

又比如 L1-07, 找差距最小的分房间情况, 题目有说1个的时候不成立, 但哥们还是WA了好几发因为没注意这个条件, 甚至都给题目简化了一下写注释里也给这事忘了。

天梯赛很少考算法题, 大部分都是基础题目, 还好这回没考时间日期之类的, 不然再寄一次(去年还说好好写点)。准备的时候多刷点 PTA L1/L2 题目就行了, 像 L3 之类的, 除非你开考一小时内给L2L1全写了, 有充裕的时间来整这些难题, 才推荐尝试。

好好读题, 别急, 一急就得

附部分AC代码

包含 L1~L2-01 的, 那些我没过但混到了20分的就不贴出来了, 以免给各位引沟里(

L1-02

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    printf("%d\n", a+b - 16);
    printf("%d\n", a+b - 3);
    printf("%d\n", a+b - 1);
    printf("%d\n", a+b);
    
    return 0;
}

L1-03

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,k;
    string x;
    cin >> n >> x >> m >> k;
    if(k == n) cout << "mei you mai " << x << " de\n";
    else if(k == m) cout << "kan dao le mai "<< x << " de\n";
    else cout << "wang le zhao mai " << x << " de\n";
    
    return 0;
}

L1-04

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    while(n--)
    {
        int a,b, c;
        cin >> a >> b >> c;
        if(c == a*b) cout << "Lv Yan\n";
        else if( c== a + b) cout << "Tu Dou\n";
        else cout << "zhe du shi sha ya!\n";
    }
    
    
    return 0;
}

L1-05

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    int a[110] = {};
    cin >> n;
    for(int i = 1; i <= n; i++)
           cin >> a[i];
    cin >> m;
    while(m--)
    {
        bool flag = true;
        int res = 0;
        for(int i = 1; i <= n; i++)
        {
            int t;
            cin >> t;
            res += t;
            if(t && t != a[i]) flag = false;
        }
        if(!flag || !res) cout << "Ai Ya\n";
        else cout << "Da Jiang!!!\n";
    }
    
    return 0;
}

L1-06

#include <bits/stdc++.h>
using namespace std;
string cy;

void cut(string &s, int l, int r)
{
    string t = s.substr(0, l - 1);
    cy = s.substr(l - 1, r - l + 1);
    t += s.substr(r);
    s = t;
}

void past(string &s, string pre, string end)
{
    int l = -1, r = -1;
    for (int i = 0; i < s.size(); i++)
        if (s[i] == pre[0])
        {
            int j = 0, u = i;
            while (j < pre.size() && u < s.size() && s[u] == pre[j])
                u++, j++;
            if (j == pre.size() && end == s.substr(i + pre.size(), end.size()))
            {
                l = i;
                break;
            }
        }
    if (l != -1)
    {
        string t = s.substr(0, l + pre.size());
        t += cy;
        t += s.substr(l + pre.size());
        s = t;
        return;
    }
    else
    {
        s += cy;
        return;
    }
}

int main()
{
    string s;
    cin >> s;
    int n;
    cin >> n;
    while (n--)
    {
        int l, r;
        string pre, end;
        cin >> l >> r >> pre >> end;
        cut(s, l, r);
        past(s, pre, end);
        cy = "";
    }
    cout << s << endl;

    return 0;
}

L1-07

#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int main()
{
    int n,m, k;
    cin >> n >> m >> k;
    int res1 = -1, res2 = -1, dist = INF;
    for(int i = 1; i < k; i++)
    {
        int j = k - i;
        if(n % i == 0 && m % j == 0)
        {
            int r1 = n/i, r2 = m/j;
            if(r1 == 1 || r2 == 1) continue;
            if(abs(r2-r1) < dist)
            {
                res1 = i, res2 = j;
                dist = abs(r2 - r1);
            }
        }
    }
    if(res1 == -1) cout << "No Solution\n";
    else cout << res1 << " " << res2 << endl;
    
    return 0;
}

L1-08

#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int get(int x)
{
    int res = 0;
    while (x)
    {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        int a, b;
        cin >> a >> b;
        int Sa = get(a), Sb = get(b);
        bool f1 = a % Sb == 0, f2 = b % Sa == 0;
        if (f1 && !f2)
            cout << "A\n";
        else if (!f1 && f2)
            cout << "B\n";
        else if (a >= b)
            cout << "A\n";
        else
            cout << "B\n";
    }

    return 0;
}

L2-01

#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int c[N], top_c;
int a[N], top_a;
int n;

int main()
{
    cin >> n;
    int max_length = 0, cnt = 0;
    while (n--)
    {
        int t;
        cin >> t;
        if (!top_a || t < a[top_a])
            a[++top_a] = t;
        else if (!top_c || t > c[top_c])
            c[++top_c] = t;
        else
        {
            max_length = max(max_length, top_a);
            top_a = 0;
            cnt++;
            while (top_c && c[top_c] > t)
                a[++top_a] = c[top_c--];
            a[++top_a] = t;
        }
    }
    if (top_a)
    {
        cnt++;
        max_length = max(max_length, top_a);
        top_a = 0;
    }
    if (top_c)
    {
        cnt++;
        max_length = max(max_length, top_c);
        top_c = 0;
    }

    cout << cnt << " " << max_length << endl;
    return 0;
}