黄大队要是还这状态,现场赛就只能靠哥的手速了。。完全没有讨论。根本提不出可靠的想法以及否定错误的想法。
A 水题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /************************************************************************* > File Name: a.cpp > Author: skt > Mail: sktsxy@gmail.com > Created Time: 2014年09月07日 星期日 12时04分15秒 ************************************************************************/ #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <queue> #include <bitset> #include <algorithm> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <memory.h> #include <cassert> // #pragma comment(linker,"/STACK:102400000,102400000") using namespace std; #define LL long long #define pb push_back #define mp make_pair #define PI acos(-1.0) #define eps 1e-8 #define x first #define y second #define MAXN 55 template <typename T> inline T Max(T a, T b) {return a>b?a:b;} template <typename T> inline T Min(T a, T b) {return a<b?a:b;} typedef pair<int, int> PII; typedef vector<int> vi; int T, N, H[MAXN]; void work() { scanf("%d", &N); for (int i = 1; i <= N; i ++) { scanf("%d", &H[i]); } int cnt = 0; for (int i = 2; i < N; i ++) { if (H[i] > H[i - 1] && H[i] > H[i + 1]) { cnt ++; } } printf("%d\n", cnt); } int main() { scanf("%d", &T); while (T --) { work(); } return 0; } |
C 被黄大队误导,说是强联通缩点,结果还让哥在敲,后来,我发现不对,只是简单的BFS。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | /************************************************************************* > File Name: c.cpp > Author: skt > Mail: sktsxy@gmail.com > Created Time: 2014年09月07日 星期日 14时55分20秒 ************************************************************************/ #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <queue> #include <bitset> #include <algorithm> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <memory.h> #include <cassert> // #pragma comment(linker,"/STACK:102400000,102400000") using namespace std; #define LL long long #define pb push_back #define mp make_pair #define PI acos(-1.0) #define eps 1e-8 #define x first #define y second #define MAXN 100005 template <typename T> inline T Max(T a, T b) {return a>b?a:b;} template <typename T> inline T Min(T a, T b) {return a<b?a:b;} typedef pair<int, int> PII; typedef vector<int> vi; int T, N, M, K, L, head[MAXN], cnt, a[MAXN], b[MAXN], u, v, rank[MAXN]; bool vis[MAXN]; struct Edge { int v, next; } p[MAXN << 2]; void init() { memset(p, 0, sizeof(p)); fill(head, head + MAXN, -1); memset(vis, 0, sizeof(vis)); cnt = 0; } void addEdge(int u, int v) { p[cnt].v = v; p[cnt].next = head[u]; head[u] = cnt ++; } struct Node { int v, pos; Node() {} Node(int v, int pos):v(v), pos(pos) {} bool operator < (const Node next) const { return v > next.v; } }; bool gao(int u) { priority_queue <Node> Q; vis[u] = true; Q.push(Node(1, u)); int cnt = 1; while (!Q.empty()) { Node now = Q.top(); Q.pop(); int u = now.pos; if (now.v > 0 && now.v != cnt) { return false; } for (int i = head[u]; i != -1; i = p[i].next) { int v = p[i].v; if (!vis[v]) { vis[v] = true; Q.push(Node(rank[v], v)); } } if (now.v) { cnt ++; } } if (cnt > K) { return true; } else { return false; } } void dfs(int u) { vis[u] = true; for (int i = head[u]; i != -1; i = p[i].next) { int v = p[i].v; if (!vis[v]) { dfs(v); } } } void work() { init(); scanf("%d %d %d", &N, &M, &K); for (int i = 1; i <= K; i ++) { scanf("%d", &a[i]); } for (int i = 1; i <= M; i ++) { scanf("%d %d", &u, &v); addEdge(u, v); addEdge(v, u); } scanf("%d", &L); memset(rank, 0, sizeof(rank)); for (int i = 1; i <= L; i ++) { scanf("%d", &b[i]); rank[b[i]] = i; } memset(vis, false, sizeof(vis)); dfs(1); for (int i = 1; i <= N; i ++) { if (!vis[i]) { printf("No\n"); return ; } } memset(vis, false, sizeof(vis)); if (L < K) { printf("No\n"); return ; } if (gao(b[1])) { printf("Yes\n"); return ; } else { printf("No\n"); return ; } } int main() { scanf("%d", &T); while (T --) { work(); } return 0; } |
J题,水题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /************************************************************************* > File Name: j.cpp > Author: skt > Mail: sktsxy@gmail.com > Created Time: 2014年09月07日 星期日 18时34分12秒 ************************************************************************/ #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <queue> #include <bitset> #include <algorithm> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <memory.h> #include <cassert> // #pragma comment(linker,"/STACK:102400000,102400000") using namespace std; #define LL long long #define pb push_back #define mp make_pair #define PI acos(-1.0) #define eps 1e-8 #define x first #define y second template <typename T> inline T Max(T a, T b) {return a>b?a:b;} template <typename T> inline T Min(T a, T b) {return a<b?a:b;} typedef pair<int, int> PII; typedef vector<int> vi; int T, len; string line, ans, a, b, c; bool gao() { for (int i = 1; i <= len; i ++) { for (int j = 1; j <= len; j ++) { if (i * 3 + j * 2 != len) continue; a = ans.substr(0, i); b = ans.substr(i, j); if (a == b) continue; string tmp = a + b + a + b + a; if (tmp == ans) { return true; } } } for (int i = 1; i <= len; i ++) { for (int j = 1; j <= len; j ++) { for (int k = 1; k <= len; k ++) { if (i * 3 + j * 3 + k != len) continue; a = ans.substr(0, i); b = ans.substr(i, j); c = ans.substr(i + j + i + j, k); if (a == b || b == c || a == c) continue; string tmp = a + b + a + b + c + a + b; if (tmp == ans) { return true; } } } } return false; } void work() { cin >> line; ans = ""; for (int i = 0; i < line.length(); i ++) { if (line[i] >= '0' && line[i] <= '9') { ans = ans + line[i]; } if (line[i] >= 'a' && line[i] <= 'z') { ans = ans + line[i]; } if (line[i] >= 'A' && line[i] <= 'Z') { ans = ans + line[i]; } } len = ans.length(); printf("%s\n", gao() ? "Yes" : "No"); } int main() { scanf("%d", &T); while (T --) { work(); } return 0; } |