# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
305099 | phathnv | Strah (COCI18_strah) | C++11 | 123 ms | 70904 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define taskname "Strah"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 2001;
int m, n;
char s[N][N];
int h[N];
ll sumS[N][N], sumH[N][N];
void readInput(){
scanf("%d %d", &m, &n);
for(int i = 1; i <= m; i++)
scanf("%s", s[i] + 1);
}
void solve(){
ll res = 0;
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++)
if (s[i][j] == '.')
h[j]++;
else
h[j] = 0;
stack <int> st;
st.push(0);
h[0] = -1;
for(int j = 1; j <= n; j++){
while (h[st.top()] >= h[j])
st.pop();
int w = j - st.top();
sumS[i][j] = sumS[i][st.top()] + sumH[i][st.top()] * w;
sumS[i][j] += (ll) h[j] * (h[j] + 1) * w * (w + 1) / 4;
sumH[i][j] = sumH[i][st.top()] + h[j] * (h[j] + 1) / 2 * w;
st.push(j);
res += sumS[i][j];
}
}
cout << res;
}
int main(){
//freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
readInput();
solve();
return 0;
}
컴파일 시 표준 에러 (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... |