| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 337127 | BeanZ | Strah (COCI18_strah) | C++14 | 230 ms | 8248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 2e3 + 5;
long long mod = 1e9 + 7;
const int lim = 2e5;
const int lg = 18;
const int base = 311;
const long double eps = 1e-6;
char a[N][N];
ll cnt[N], l[N], r[N];
ll sum(ll u){
return u * (u + 1) / 2;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("tests.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n, m;
cin >> n >> m;
ll ans = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
cin >> a[i][j];
if (a[i][j] == '.') cnt[j]++;
else cnt[j] = 0;
}
vector<ll> st;
for (int j = 1; j <= m; j++){
while (st.size()){
if (cnt[st.back()] >= cnt[j]) st.pop_back();
else break;
}
if (st.size()) l[j] = st.back() + 1;
else l[j] = 1;
st.push_back(j);
}
st.clear();
for (int j = m; j >= 1; j--){
while (st.size()){
if (cnt[st.back()] > cnt[j]) st.pop_back();
else break;
}
if (st.size()) r[j] = st.back() - 1;
else r[j] = m;
st.push_back(j);
}
for (int j = 1; j <= m; j++){
ll lf = j - l[j] + 1;
ll rt = r[j] - j + 1;
ll tot = lf * sum(rt) + rt * sum(lf) - lf * rt;
ans = ans + tot * sum(cnt[j]);
}
}
cout << ans;
}
/*
3 3
...
...
...
Ans:
Out:
*/
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
| # | 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
