Regional 2011, Asia - Kuala Lumpur 解题报告
A.Smooth Visualization
不说了。大水题
B.Arnooks's Defensive Line
貌似judge挂了。数据结构吧。
最暴力的方法应该是二维树状数组。。不过要离散化
其他的方法没研究过
C.Equivalence
不多说。基本的四则运算表达式。
给参数赋随机值,判断是否相等。我跑了10遍。
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#include <map>#include <cmath>#include <set>#include <vector>#include <queue>#include <stack>#include <ctime>#define MAXN 100007#define eps 1e-7#define INF 1000000007using namespace std;char Str1[MAXN], Str2[MAXN];long long h1[MAXN], h2[MAXN];long long mod = INF;int main(){ int T; scanf("%d", &T); while(T--) { scanf("%s%s", Str1, Str2); int len1 = strlen(Str1); int len2 = strlen(Str2); long long now = 1; h1[len1] = 0; int ans = 0; for(int i = len1 - 1; i >= 0; i--) { h1[i] = (h1[i + 1] + (long long)(Str1[i] - 'a') * now) % mod; now = now * 101LL % mod; } for(int i = 0; i < len2; i++) { if(i == 0) h2[i] = Str2[i] - 'a'; else h2[i] = (h2[i - 1] * 101LL + (long long)(Str2[i] - 'a')) % mod; if(len1 - 1 - i >= 0 && h2[i] == h1[len1 - 1 - i]) ans++; } printf("%d\n", ans + 1); } return 0;}BFS或者SPFA 随便过吧。。
I.Shortest Leash
就不说某人用
random_shuffle做的了。
正解反正我不太会。。有待了解