總結——關於2017 10 26測試的分析總結

来源:互联网 发布:电商原生app源码 编辑:程序博客网 时间:2024/06/05 04:53

NOIP 2017 模拟



10 26


前言:

虽然今天是学校运动会,但作为一名蒟蒻,被困在机房,闻耳旁萧萧声,望眼前坑爹题,

怀念良心凯爷,不亦悲乎。。。。。



T1: 





首先,这道题充满了坑,题目中的某种情况,连出题人都没考虑到。。。。。。

gyr da lao 独自在风中凌乱。。。


——正解思路:

——我的乱搞:

本来写的是正解的,但是tmd每组数据除了最后一行,末尾竟然中出一个空格,导致最后

一组数据两个字符串长度不一样,于是就很愉快的WA了。。。。





算了算了,出家人不说脏话。。



满载悲伤的代码:


#pragma GCC optimize("O3")#include <fstream>#include <cstring>#include <map>#pragma warning(disable : 4995)using namespace std;int t;char j[1024], c[1024];map <char, char> m;int main () {scanf ("%d\n", &t);while (t--) {gets (j);gets (c);bool flag = false;int fix1 = 0, fix2 = 0;for (int i = strlen(j) - 1; j[i] == ' '; i--) ++fix1;for (int i = strlen(c) - 1; c[i] == ' '; i--) ++fix2;if ((strlen(j) - fix1) ^ (strlen(c) - fix2)) goto Brk;m.clear();for (int i = 0, k = strlen(j) - fix1; i < k; i++) {if (isalpha(j[i])) {if (!isalpha(c[i])) goto Brk;else if (m[j[i]] and m[j[i]] != c[i]) goto Brk;else m[j[i]] = c[i];} else if (j[i] != c[i]) goto Brk;}flag = true;Brk : ;puts (flag ? "1" : "0");}return 0;}



T2 :


顿时老衲要还俗了。。。。


题目:






旁边的同志写了个SPFA,然后果不其然被卡常。

尔等写后来写迪杰斯特拉,在OJ上各种花式TLE,最后苟且卡过。。。。。。


——正解思路:



——我的乱搞:

迪杰斯特拉,但是没有用并查集,,于是愉快的WA了。。


满载悲伤的代码:

#pragma GCC optimize("O3")#include <fstream>#include <algorithm>#include <cstring>#include <queue>using namespace std;struct node {int to, nxt, t, u;long long c;inline friend bool operator < (const node&a, const node&b) {return a.t < b.t;}}a[2000005], f[1000005];int l, n, m, d, S, T;int first[500005],fa[500005];bool bj[500005];long long dis[500005];inline int read(){int i = 0;char c = getchar();while (!isdigit(c)) c = getchar();while (isdigit(c)) i = i * 10 + c - 48, c = getchar();return i;}inline void write (long long x) {signed num = 0;char c[20];do c[++num] = x % 10 + 48, x /= 10; while (x);while (num) putchar(c[num--]);putchar(' ');}inline void add(int x, int y, int z, int zz){a[++l].to = y;a[l].nxt = first[x];first[x] = l;a[l].t = z;a[l].u = x;a[l].c = 1ll * z * zz;}inline int getfa (int x){return fa[x] == x ? x : fa[x] = getfa(fa[x]);}int main(){n = read();m = read();for(int i = 1; i <= m; ++i){f[i].u = read();fa[f[i].u] = f[i].u;f[i].to = read();fa[f[i].to] = f[i].to;f[i].t = read();f[i].nxt = read();}sort(f + 1, f + m + 1);S = read();T = read();for(int i = 1; i <= m; i++){int fx = getfa (f[i].u),fy = getfa (f[i].to);if(fx != fy){fa[fy] = fx;d = f[i].t;}if(getfa(S) == getfa(T)) break;}for(int i = 1; i <= m; ++i)if(f[i].t <= d){add (f[i].u, f[i].to, f[i].t, f[i].nxt);add (f[i].to, f[i].u, f[i].t, f[i].nxt);}else break;memset (dis, 127, sizeof (dis));priority_queue < pair<long long, int> >que;dis[S] = 0;que.push (make_pair (0, S));while(!que.empty()){pair <long long, int> now = que.top();que.pop();if (now.second == T) break;if (bj[now.second]) continue;bj[now.second] = 1;for(int p = first[now.second]; p; p = a[p].nxt)if(dis[a[p].to] > dis[now.second] + a[p].c and !bj[a[p].to])que.push (make_pair (- (dis[a[p].to] = dis[now.second] + a[p].c), a[p].to));}write (d);write (dis[T]);return 0;}







T3:



题目:





——正解思路:




——我的乱搞:

我。。放弃治疗。。








满载悲伤的代码:


#pragma GCC optimize("O3")#include <fstream>#include <algorithm>#define s1(j + k + (len[i] << 1))#define s2(j + k + len[i])using namespace std;int n, T, x, y, z, cnt, ans;int w[303], t[303], first[303], to[606], len[606], next[606];int F[303], G[303], H[303], f[303][303], g[303][303], h[303][303];template <typename T>class Max {public :T max (T x, T y){return x > y ? x : y;}T max (T x, T y, T z){return x > max (y, z) ? x : max (y, z);}T max (T x, T y, T z, T u)  {return max (x, y) > max (z, u) ? max (x, y) : max (z, u);}};class Read {public :void read (int &x);void read (int &x, int &y){read (x); read (y);}void read (int &x, int &y, int &z)  {read (x); read (y); read (z);}};void Read::read (int &x) {x = 0;char c = getchar();while (!isdigit(c)) c = getchar();while (isdigit(c)) x = x * 10 + c - 48, c = getchar();}inline void add (int x, int y, int z) {to[++cnt] = y;len[cnt]  = z;next[cnt] = first[x];first[x]  = cnt;}void dfs (int x, int fa) {for (int i = t[x]; i <= T; i++) f[x][i] = g[x][i] = h[x][i] = w[x];Max <int> M;for (int i = first[x]; i; i = next[i]) if (to[i] != fa) {dfs (to[i], x);for (int j = 0; j <= T; j++) F[j] = f[x][j], G[j] = g[x][j], H[j] = h[x][j];for (int j = t[x]; j <= T and (len[i] << 1) + j <= T; j++)for (int k = 0; s1 <= T; k++) {f[x][s1] = M.max (F[j] + f[to[i]][k], f[x][s1]);g[x][s1] = M.max (G[j] + f[to[i]][k], g[x][s1]);h[x][s1] = M.max (H[j] + f[to[i]][k], h[x][s1], F[j] + h[to[i]][k]);}for (int j = t[x]; j <= T and j + len[i] <= T; j++)for (int k = 0; s2 <= T; k++) {g[x][s2] = M.max (F[j] + g[to[i]][k], g[x][s2]);h[x][s2] = M.max (G[j] + g[to[i]][k], h[x][s2]);}}}int main () {Read R;R.read (n, T);for (int i = 1; i <= n; i++) R.read (w[i]);for (int i = 1; i <= n; i++) R.read (t[i]);for (int i = 1; i < n; i++) {R.read (x, y, z);add (x, y, z);add (y, x, z);}dfs (1, 0);Max <int> M;for (int i = 1; i <= n; i++)for (int j = 0; j <= T; j++)ans = M.max (ans, f[i][j], g[i][j], h[i][j]);printf ("%d\n", ans);return 0;}



原创粉丝点击