2019.10.18考试解题报告

总结

期望得分:\(100 + 100 + 10\)
实际得分:\(0 + 20 + 10\)

完美.

今天的考试格外完美,\(T1\)做了*\(2.5h\),最后换来了\(0\)分的好成绩,史无前例美妙绝伦,我竟然不删调试,做得?好。
\(T2\)是个好题,是个好阅读题,\(n\)和\(m\)写反了,样例给的是\(n\)和\(m\)相等的情况,最终完美\(100—>20\),我竟然这么粗心,题目竟然没读好,做得?好.
\(T3\)没时间了,都耗在\(T1\)上了,可惜\(T1\)还没有分,做得?好.

总体来说,?好,做得?好,做的太?好了

希望以后继续粗心马虎不看好程序,创下更好的成绩

(写下这段话,嘲讽我自己)

思路

T1

先写了\(30\)分暴力,直接\(O(n^4)\)枚举

然后写\(hash\),调不出来,最后发现初始化\(hash\)的时候写错了,改完之后看着答案对,调试的东西也忘记删了,最终完美爆零

然而考完试之后,拿我的暴力程序去测试,却得了\(90\)分

意思就是……我在前半个小时,就打了\(90\)分!!

然后在最后\(10\)分上杠了两个小时!

最后还错了!

麻麻我要回家,社会太险恶了

一把辛酸泪啊!

T2

由题意可得,\(m\)是行数,\(n\)是列数,只走\(23\)个拐弯,\(n\)和\(m\)的范围又很小,所以就可以写\(n*m*23*4\)的\(dp\)了!

设\(f[i][j][k]\)表示在\((i, j)\)点走了\(k\)步获得的最大价值

因为每个点都可以重复进入,所以我们可以得到方程

\[f[i][j][k] = max(f[i][j][k], f[nx][ny][k - 1] + a[i][j])(nx,ny)是点(i, j)上下左右的四个点\]

然后就做完了

T3

首先打表找规律:

1  0
2  1
3  2        = (1 + 0) * 2
4  9        = (1 + 2) * 3
5  44       = (9 + 2) * 4
6  265      = (44 + 9)* 5
7  1854     = (265 + 44) * 6
8  14833    = ...
9  133496
10 1334961
11 14684570
12 176214841

然后发现规律是\(f[n] = (f[n - 1] + f[n - 2]) *(i - 1)\)

最后套上高精就完了

代码

T1

考场爆零代码(可能会编译失败,这告诉我,变量用\(cnm\)也不用\(hash\))

/*
By:Loceaner
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#define ull unsigned long long
using namespace std;

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    return x * f;
}

const int N = 211;

char pa[N][N], meng[N];
int n, m, a[N], l[N], ans, cnt[N];
ull p[N], hash[N][N], sjp[N];

//void work() {
//  int len = strlen(meng + 1);
//  for(int i = 1; i <= m; i++) {
//      for(int j = 1; j <= len; j++) {
//          if(meng[j] == pa[i][1]) {
//              int sta = j, now = j, st = 1, flag = 0;
//              while(meng[now] == pa[i][st] && st <= l[i] && now <= len) {
//                  now++, st++;
//                  flag = 1;
//              }
//              if(flag) now--, st--;
//              if(st == l[i]) ans += sta * a[i];
//          }
//      }
//  }
//}

bool query(int l1, int r1,int now) {
    ull h1, h2;
    h1 = sjp[r1] - sjp[l1 - 1] * p[r1 - l1 + 1];
    h2 = hash[now][l[now]];
    return h1 == h2;
}

void work2() {//hash
    memset(sjp, 0, sizeof(sjp));
    int len = strlen(meng + 1);
    for(int i = 1; i <= len; i++) {
        sjp[i] = sjp[i - 1] * 27 + meng[i] - 'a' + 1;
    }
    for(int i = 1; i <= len; i++) cout << sjp[i] << ' ';
    cout << '\n';
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= len; j++) {
            if(meng[j] == pa[i][1]) {
                if(query(j, j + l[i] - 1, i)) ans += j * a[i];
            }
        }
    }
}

int main() {
    freopen("dream.in", "r", stdin);
    freopen("dream.out", "w", stdout);
    n = read(), m = read();
    p[0] = 1;
    for(int i = 1; i <= 200; i++) p[i] = p[i - 1] * 27ull;
    for(int i = 1; i <= m; i++) scanf("%s", pa[i] + 1), l[i] = strlen(pa[i] + 1);
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= l[i]; j++)
            hash[i][j] = hash[i][j - 1] * 27 + pa[i][j] - 'a' + 1;
    for(int i = 1; i <= m; i++) a[i] = read();
    for(int i = 1; i <= n; i++) scanf("%s", meng + 1), work2();
    cout << ans << '\n';
    return 0;
}
/*
1 1
a
1
aaaaaaa

2 2
abc
def
1
2
abcdef
defabc
*/

可以拿\(90\)的暴力

/*
By:Loceaner
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#define ull unsigned long long
using namespace std;

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    return x * f;
}

const int N = 211;

char pa[N][N], meng[N];
int n, m, a[N], l[N], ans, cnt[N];
ull p[N], cnm[N][N], sjp[N];

void work() {
    int len = strlen(meng + 1);
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= len; j++) {
            if(meng[j] == pa[i][1]) {
                int sta = j, now = j, st = 1, flag = 0;
                while(meng[now] == pa[i][st] && st <= l[i] && now <= len) {
                    now++, st++;
                    flag = 1;
                }
                if(flag) now--, st--;
                if(st == l[i]) ans += sta * a[i];
            }
        }
    }
}

int main() {
    freopen("dream.in", "r", stdin);
    freopen("dream.out", "w", stdout);
    n = read(), m = read();
    for(int i = 1; i <= m; i++) scanf("%s", pa[i] + 1), l[i] = strlen(pa[i] + 1);
    for(int i = 1; i <= m; i++) a[i] = read();
    for(int i = 1; i <= n; i++) scanf("%s", meng + 1), work();
    cout << ans << '\n';
    return 0;
}
/*
1 1
a
1
aaaaaaa

2 2
abc
def
1
2
abcdef
defabc
*/

\(hash\)满分

/*
By:Loceaner
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#define ull unsigned long long
using namespace std;

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    return x * f;
}

const int N = 211;

char pa[N][N], meng[N];
int n, m, a[N], l[N], ans, cnt[N];
ull p[N], cnm[N][N], sjp[N];

bool query(int l1, int r1,int now) {
    ull h1, h2;
    h1 = sjp[r1] - sjp[l1 - 1] * p[r1 - l1 + 1];
    h2 = cnm[now][l[now]];
    return h1 == h2;
}

void work2() {//cnm
    memset(sjp, 0, sizeof(sjp));
    int len = strlen(meng + 1);
    for(int i = 1; i <= len; i++) {
        sjp[i] = sjp[i - 1] * 27 + meng[i] - 'a' + 1;
    }
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= len; j++) {
            if(meng[j] == pa[i][1]) {
                if(query(j, j + l[i] - 1, i)) ans += j * a[i];
            }
        }
    }
}

int main() {
    freopen("dream.in", "r", stdin);
    freopen("dream.out", "w", stdout);
    n = read(), m = read();
    p[0] = 1;
    for(int i = 1; i <= 200; i++) p[i] = p[i - 1] * 27ull;
    for(int i = 1; i <= m; i++) scanf("%s", pa[i] + 1), l[i] = strlen(pa[i] + 1);
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= l[i]; j++)
            cnm[i][j] = cnm[i][j - 1] * 27 + pa[i][j] - 'a' + 1;
    for(int i = 1; i <= m; i++) a[i] = read();
    for(int i = 1; i <= n; i++) scanf("%s", meng + 1), work2();
    cout << ans << '\n';
    return 0;
}
/*
1 1
a
1
aaaaaaa

2 2
abc
def
1
2
abcdef
defabc
*/

T2

考场\(20\)代码

/*
By:Loceaner
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#define int long long
using namespace std;

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    return x * f;
}

const int N = 311;

int n, m, sx, sy, a[N][N], f[N][N][23]; 

const int dx[4] = {0, 1, -1, 0};
const int dy[4] = {1, 0, 0, -1};

signed main() {
    freopen("corner.in", "r", stdin);
    freopen("corner.out", "w", stdout);
    memset(f, -1, sizeof(f));
    n = read(), m = read();
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            a[i][j] = read();
            if(a[i][j] == 0) f[i][j][0] = 0;
        }
    }
    for(int k = 1; k <= 23; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                if(a[i][j] != -1 && a[i][j] != 0) {
                    for(int l = 0; l <= 3; l++) {
                        int nx = i + dx[l], ny = j + dy[l];
                        if(nx >= 1 && nx <= n && ny >= 1 && ny <= m && a[nx][ny] >= 0 && f[nx][ny][k - 1] != -1) {
                            f[i][j][k] = max(f[i][j][k], f[nx][ny][k - 1] + a[i][j]);
                        }
                    }
                }
            }
        }
    }
    int ans = -0x3f3f3f3f;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            ans = max(ans, f[i][j][23]);
        }
    }
    cout << ans << "\n";
    return 0;
}

改改\(m\)和\(n\)之后\(ac\)

/*
By:Loceaner
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#define int long long
using namespace std;

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    return x * f;
}

const int N = 311;

int n, m, sx, sy, a[N][N], f[N][N][23]; 

const int dx[4] = {0, 1, -1, 0};
const int dy[4] = {1, 0, 0, -1};

signed main() {
    freopen("corner.in", "r", stdin);
    freopen("corner.out", "w", stdout);
    memset(f, -1, sizeof(f));
    m = read(), n = read();
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            a[i][j] = read();
            if(a[i][j] == 0) f[i][j][0] = 0;
        }
    }
    for(int k = 1; k <= 23; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                if(a[i][j] != -1 && a[i][j] != 0) {
                    for(int l = 0; l <= 3; l++) {
                        int nx = i + dx[l], ny = j + dy[l];
                        if(nx >= 1 && nx <= n && ny >= 1 && ny <= m && a[nx][ny] >= 0 && f[nx][ny][k - 1] != -1) {
                            f[i][j][k] = max(f[i][j][k], f[nx][ny][k - 1] + a[i][j]);
                        }
                    }
                }
            }
        }
    }
    int ans = -0x3f3f3f3f;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            ans = max(ans, f[i][j][23]);
        }
    }
    cout << ans << "\n";
    return 0;
}

T3

正解(\(from\ gyh dalao ? : zlq\))

#include<cstdio>
#include<iostream>
#include<vector>
#include<iomanip>
#include<cassert>
#include<algorithm>
#include<cstring>
#define rg register
#define LL long long
const int MARX = 1010;
const int Big_B = 10; const int Big_L = 1;
inline int intcmp_ (int a, int b) { if (a > b) return 1; return a < b ? -1 : 0; }
struct Int
{
    inline int max(int a, int b) {return a > b ? a : b;}
    inline int min(int a, int b) {return a < b ? a : b;}
    std :: vector <int> c; Int () {}
    Int (int x) { for (; x > 0; c.push_back (x % Big_B), x /= Big_B); }
    Int (LL x) { for (; x > 0; c.push_back (x % Big_B), x /= Big_B); }
    inline void CrZ () { for (; !c.empty () && c.back () == 0; c.pop_back ()); }
    inline Int &operator += (const Int &rhs)
    {
        c.resize (max (c.size (), rhs.c.size ())); rg int i, t = 0, S;
        for (i = 0, S = rhs.c.size (); i < S; ++ i)
          c[i] += rhs.c[i] + t, t = c[i] >= Big_B, c[i] -= Big_B & (-t);
        for (i = rhs.c.size (), S = c.size (); t && i < S; ++ i)
          c[i] += t, t = c[i] >= Big_B, c[i] -= Big_B & (-t);
        if (t) c.push_back (t); return *this;
    }
    inline Int &operator *= (const Int &rhs)
    {
        rg int na = c.size (), i, j, S, ai;
        c.resize (na + rhs.c.size ()); LL t;
        for (i = na - 1; i >= 0; -- i)
        {
            ai = c[i], t = 0, c[i] = 0;
            for (j = 0, S = rhs.c.size (); j < S; ++ j)
            {
              t += c[i + j] + (LL) ai * rhs.c[j];
              c[i + j] = t % Big_B, t /= Big_B;
            }
            for (j = rhs.c.size (), S = c.size (); t != 0 && i + j < S; ++ j)
              t += c[i + j], c[i + j] = t % Big_B, t /= Big_B;
            assert (t == 0);
        }
        CrZ (); return *this;
    }
    friend inline Int operator + (const Int &lhs, const Int &rhs)
    { Int res = lhs; return res += rhs; }
    friend inline Int operator * (const Int &lhs, const Int &rhs)
    { Int res = lhs; return res *= rhs; }
    friend inline std :: ostream &operator << (std :: ostream &out, const Int &rhs)
    {
        if (rhs.c.size () == 0) out << "0";
        else
        {
          out << rhs.c.back ();
          for (rg int i = rhs.c.size () - 2; i >= 0; -- i)
            out << std :: setfill ('0') << std :: setw (Big_L) << rhs.c[i];
        }
        return out;
    }
};
//=============================================================
LL n;
Int f[MARX];
//=============================================================
inline LL read()
{
    LL s = 1, w=0; char ch=getchar();
    for(; !isdigit(ch); ch=getchar()) if(ch=='-') s =-1;
    for(; isdigit(ch); ch=getchar()) w = w*10+ch-'0';
    return s*w;
}
//=============================================================
signed main()
{
    freopen("keke.in","r",stdin);
    freopen("keke.out","w",stdout);
    n = read();
    f[1] = 0, f[2] = 1;
    if(n <= 2) { std::cout << f[n]; return 0; }
    for(rg int i = 3; i <= n; i ++) f[i] = (f[i - 1] + f[i - 2]) * (i - 1);
    std::cout << f[n];
}

原文地址:https://www.cnblogs.com/loceaner/p/11698390.html

时间: 2024-07-29 19:13:40

2019.10.18考试解题报告的相关文章

2014年春季大学先修课考试 解题报告

A:吃糖果 总时间限制:  1000ms 内存限制:  65536kB 描述 名名的妈妈从外地出差回来,带了一盒好吃又精美的巧克力给名名(盒内共有 N 块巧克力,20 > N >0).妈妈告诉名名每天可以吃一块或者两块巧克力.假设名名每天都吃巧克力,问名名共有多少种不同的吃完巧克力的方案.例如:如果N=1,则名名第1天就吃掉它,共有1种方案:如果N=2,则名名可以第1天吃1块,第2天吃1块,也可以第1天吃2块,共有2种方案:如果N=3,则名名第1天可以吃1块,剩2块,也可以第1天吃2块剩1块,

2019.3.18考试&amp;2019.3.19考试

2019.3.18 C O D E T1 树上直接贪心,环上for一遍贪心 T2 正反都做一遍DP T3 观察到顺序不影响答案,分块打标记 2019.3.19 肥肠爆芡,因为沙茶博主昨天在学校的煞笔食堂吃坏了肚子,所以这场考试咕咕了 我佛了 一定补这两场.jpg 原文地址:https://www.cnblogs.com/ydnhaha/p/10558495.html

7.18 DP考试解题报告

今天的考试真的是天崩地裂,写了的三个题全炸...然而谁叫我弱+不注意细节呢???真的要扇耳光... T1:题意:一段区间的高度为这个区间中高度的最小值,给定n个宽度,求每个宽度的期望高度 40% :算出长度为x的区间的所有的最小值的取值的和,除以总的方案数(n-x+1),用ST表预处理可以n^2;(记得开long long) 100%:对于每个点求出他取最小值的区间,即用两遍单调栈求出左,右边第一个小于他的值...记为l[i],和r[i],这一步和影魔很像: 对于当前这一个点,考虑以他为最小值,

2019.10.02考试报告

T1 一般都能想到二分+取前m大正值,但是复杂度无法承受,我们发现要的是sum值,并不需要每个位置的准确值, 所以用可以nth_element把大于第m大的放右边即可.(原来nth还可以这么用). nth_element实现: 每次找一个base,小于base的放右边,大于的放右边 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e8+10; 4 int n,k,a[N]; 5 inline int read()

2019.10.08考试报告

T1 用一个堆维护最小的是谁,每次加入一个值x时查询堆顶是否小于x,有则买top卖x,之后分为是不是反悔操作判断要不要把pop. 然而好像其他人都push两个来进行反悔操作. 1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstring> 5 #include<queue> 6 #define int long long 7 using namespace

2019.08.18考试报告

早上和skyh立flag:它在11机房虐场,我在10机房虐场.然而它考了rk1,我只拿到了rk3. T1 wxh学长讲的原题,13分钟打完正解+暴力+对拍拿到100分. T2正解复杂度$ O(n*log2(n)) $,我打的程序多了一个log,但还是可过的. 打完暴力后再打的正解,似乎很难实现? 调了1h左右,对怕出了错,发现算法需要二分找边界,所以直接先弃下去打T3了. T3码了一个dfs成功拿到10分... T2最后终于调过去啦,最后为了求稳进行了测试点分治最后WA了80. 在徐嘉一的帮助下

2019.10.03考试报告

10min:打完T1,为了不滑天下之大稽,打了一个对拍 50min:打完了T2T3的暴力,准备推一推T2. 2h:打完T3的正解和对拍. 3h:T3写了一个O(n*log2(n)*log2(n))的40分算法. 最后调T3的60分线段树调到考试结束也没过对拍. 期望分数:240 实际得分:200 就是因为这一个智障级的错误! 题解: T1 对于每个a[i],O(sqrt(a[i]))预处理出ta的所有约数,用map或hashmap存起来即可. T2 把商品和询问离线并按时间排序,枚举时间,是商品

2014年秋季大学先修课考试 解题报告

A:细菌的战争 总时间限制:  1000ms 内存限制:  65536kB 描述 有两种细菌,一种是有害菌,繁殖能力很强,每小时会繁殖一倍:另一种是有益菌,繁殖能力较弱,每小时能繁殖百分之五.但在单位体积内,当有害菌数量超过一 百万时,多出的细菌会因为密度太大而迅速死亡,直到细菌数量下降到一百万.已知每个有益菌每小时能消灭一个有害菌.给定单位体积内有害菌和有益菌的初始数 量,请问多少小时后,有害菌将被有益菌消灭干净? 输入 输入的第一行为一个整数n,表示后边有n组数据.每组数据占一行,有两个整数

10 noip 机器翻译 解题报告

题目描述 Description 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义 来替换.对于每个英文单词,软件会先在内存中查找这个单词的中文含义,如果内存中有, 软件就会用它进行翻译:如果内存中没有,软件就会在外存中的词典内查找,查出单词的中 文含义然后翻译,并将这个单词和译义放入内存,以备后续的查找和翻译. 假设内存中有M个单元,每单元能存放一个单词和译义.每当软件将一个新单词存入 内存前,如