视差网站,建设个人网站的心得体会,市场推广工作内容,邯郸做淘宝网站远古的回忆。
把变换一个字符视为边权为 1 1 1 的边#xff0c;即求最长路。
最长路不好搞#xff0c;考虑转补集最短路#xff08;容易感性理解#xff09;#xff0c;BFS 即可。
#includebits/stdc.h
#define int long long
using namespace std;const int …远古的回忆。
把变换一个字符视为边权为 1 1 1 的边即求最长路。
最长路不好搞考虑转补集最短路容易感性理解BFS 即可。
#includebits/stdc.h
#define int long long
using namespace std;const int N 1e5 5;int n, m, a[N], step[118];signed main()
{ios::sync_with_stdio(0); cin.tie(0);memset(step, 0x3f, sizeof(step));cin m n;int ALL (1 m) - 1;queue int q;for(int i1; in; i){ for(int j0; jm; j){char x; cin x; if(x G) a[i] (1 j);}step[a[i]] 0, q.push(a[i]);}while(!q.empty()){int curs q.front(); q.pop();for(int i0; i18; i){int news curs^(1i);if(step[news] step[curs] 1)step[news] step[curs] 1, q.push(news);}}for(int i1; in; i)cout m - step[ALL-a[i]] \n;
}