이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 50 + 5;
map<vector<int>, long long> mp[2];
map<vector<int>, int> dp[2];
int n, m, par[M], idx[M];
char c[N][M];
int get_par(int u) {
	return ~par[u]? par[u] = get_par(par[u]): u;
}
void merge(int u, int v) {
	u = get_par(u);
	v = get_par(v);
	if (u == v)
		return;
	if (u > v)
		swap(u, v);
	par[v] = u;
}
vector<int> merge(vector<int> A, vector<int> B) {
	memset(par, -1, sizeof par);
	memset(idx, -1, sizeof idx);
	for (int i = 0; i < m; i++)
		if (~A[i] && ~B[i]) {
			if (!~idx[B[i]])
				idx[B[i]] = A[i];
			merge(A[i], idx[B[i]]);
		}
	for (int i = 0; i < m; i++)
		if (~A[i])
			A[i] = get_par(A[i]);
	return A;
}
void read_input() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> c[i];
}
void solve() {
	long long ans = 0;
	for (int i = n - 1; ~i; i--) {
		int ted = 0;
		vector<int> help(m);
		for (int j = 0; j < m; j++) {
			if (j && c[i][j] ^ '0' && c[i][j - 1] ^ '0')
				help[j] = help[j - 1];
			else
				help[j] = c[i][j] ^ '0'? j: -1;
			ted += help[j] == j;
		}
		dp[i & 1].clear(), mp[i & 1].clear();
		dp[i & 1][help]++, mp[i & 1][help] = ted;
		for (auto [vec, k]: dp[i & 1 ^ 1]) {
			vector<int> A = merge(help, vec);
			vector<int> B = merge(vec, help);
			for (int j = ted = 0; j < m; j++) {
				ted -= vec[j] == j;
				ted += A[j] == j;
			}
			memset(idx, -1, sizeof idx);
			for (int j = 0; j < m; j++)
				if (~B[j])
					idx[B[j]] = max(idx[B[j]], A[j]);
			for (int j = 0; j < m; j++)
				if (B[j] == j)
					ted += !~idx[B[j]];
			mp[i & 1][A] += mp[i & 1 ^ 1][vec];
			mp[i & 1][A] += 1LL * k * ted;
			dp[i & 1][A] += k;
		}
		for (auto [vec, k]: mp[i & 1])
			ans += k;
	}
	cout << ans;
}
int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	read_input(), solve();
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
raspad.cpp: In function 'void solve()':
raspad.cpp:60:13: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
   for (auto [vec, k]: dp[i & 1 ^ 1]) {
             ^
raspad.cpp:60:28: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   for (auto [vec, k]: dp[i & 1 ^ 1]) {
                          ~~^~~
raspad.cpp:74:25: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
    mp[i & 1][A] += mp[i & 1 ^ 1][vec];
                       ~~^~~
raspad.cpp:78:13: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
   for (auto [vec, k]: mp[i & 1])
             ^
raspad.cpp:78:20: warning: unused variable 'vec' [-Wunused-variable]
   for (auto [vec, k]: mp[i & 1])
                    ^| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |