Submission #857703

# Submission time Handle Problem Language Result Execution time Memory
857703 2023-10-06T15:58:47 Z serifefedartar Strah (COCI18_strah) C++17
0 / 110
1000 ms 23196 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll LOGN = 18; 
const ll INF = 1e15;
const ll MAXN = 2005;

vector<int> occ[MAXN];
int N, M;
int emp[MAXN][MAXN];
ll total = 0, ans = 0;
set<pair<ll,ll>> st;

ll calc(ll x) {
	return (x * x * x + 3 * x * x + 2 * x) / 6;
}

void split(int pos) {
	pair<ll,ll> Q = *(prev(st.upper_bound(make_pair(pos, 0))));
	ans += calc(pos - Q.f) + calc(Q.f + Q.s - 1 - pos) - calc(Q.s);
	st.erase(Q);
	if (pos - Q.f > 0)
		st.insert({Q.f, pos - Q.f});
	if (Q.f + Q.s - 1 - pos > 0)
		st.insert({pos + 1, Q.f + Q.s - 1 - pos});
}

string s;
int main() {
	fast
	cin >> N >> M;

	for (int i = 1; i <= N; i++) {
		cin >> s;
		for (int j = M; j >= 1; j--) {
			if (s[j-1] == '.')
				emp[i][j] = emp[i][j+1] + 1;
		}
	}

	for (int j = 1; j <= M; j++) {
		st.clear();
		st.insert({1, N});
		ans = calc(N);
		for (int i = 1; i <= N; i++)
			occ[emp[i][j]].push_back(i);

		for (ll q = 0; q <= 2000; q++) {
			total += ans * q;
			while (occ[q].size()) {
				split(occ[q].back());
				occ[q].pop_back();
			}
		}
	}
	cout << total << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 2088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2652 KB Output is correct
2 Incorrect 23 ms 1884 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 256 ms 7112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 640 ms 10976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 435 ms 7768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 8792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 23196 KB Time limit exceeded
2 Halted 0 ms 0 KB -