|
我有毒。。。没做一道题必先交一遍没有写文件读入输出的
|
|
用不对的复杂度卡过……
虽然这个剪枝很套路但是我太垃圾所以没写 然后居然过了…… |
|
瞎写居然1a……
|
|
劲啊
|
|
直接二分答案就好
|
|
这个题真是神题,时间复杂度是O(nlog^2n)的。时间复杂度的分析着实费心!
|
|
我把j++的j写成i了
|
|
桶排喵喵喵
|
|
居然有空格!!!!!!!!!!!!
|
|
额,我的想法好像很简单的样子
|
|
这个多重背包有点诡异
![]() ![]() ![]() ![]() ![]() |
|
二分精度高了会过不了。。。。。。。。。。。。。。
垃圾题。。。。。。。。。。。。 |
|
|
|
后缀自动机真是劲啊!
|
|
后缀自动机真是劲啊
题目 1712 [POJ3415]公共子串
2017-03-08 21:05:40
|
|
mdzz f[u][0] 写成 f[i][0]调半小时》。。
|
|
一A的01背包。。不知道自己是会背这种代码了还是真的理解了
|
|
其实这是一个多源最短路的题目
#include<cstdio> #include<cstring> #include<queue> using namespace std; int n,m; int a[200][200]; int dx[] = {0,1,0,-1}; int dy[] = {1,0,-1,0}; queue<int>q,p; void bfs(){ while(!q.empty()){ int x = q.front(),y = p.front(); q.pop();p.pop(); for(int i = 0; i < 4;i++){ int xx = x + dx[i],yy = y + dy[i]; if(xx >= 1 && xx <= n && yy >= 1&& yy <= m && a[xx][yy] != 0 ){ if(a[xx][yy] == -1){ a[xx][yy] = a[x][y] + 1; q.push(xx);p.push(yy); } else{ if(a[xx][yy] > a[x][y] + 1){ a[xx][yy] = a[x][y] + 1; q.push(xx);p.push(yy); } } } } } } void input(){ scanf("%d%d", &n, &m); memset(a,-1,sizeof(a)); for(int i = 1; i <= n; i++){ char s[200]; scanf("%s", s); for(int j = 0; j < m; j++){ if(s[j] == '1'){ a[i][j+1] = 0; q.push(i);p.push(j+1); } } } } void output(){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++)printf("%d ",a[i][j]); printf("\n"); } } void solve(){ bfs(); } int main(){ freopen("bit.in","r",stdin); freopen("bit.out","w",stdout); input(); solve(); output(); } |
|
后缀自动机+链剖LCA强行作一发
|
|
递归完事儿。。。
|