# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151245 | 2019-09-02T09:59:52 Z | Ruxandra985 | Strah (COCI18_strah) | C++14 | 203 ms | 98612 KB |
#include <cstdio> using namespace std; int a[2010][2010],jos[2010][2010],st[2010]; long long s[2010][2010] , dp[2010][2010]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n,m,i,j,len,elem; char c; long long sol=0; fscanf (fin,"%d%d",&n,&m); for (i=1;i<=n;i++){ fgetc (fin); for (j=1;j<=m;j++){ c=fgetc (fin); if (c=='#') a[i][j] = 1; /// blocat } } /// precalculare jos for (i=n;i;i--){ for (j=1;j<=m;j++){ if (a[i][j] == 0) /// cate sunt in jos jos[i][j] = jos[i+1][j] + 1; else jos[i][j] = 0; } } /// fixezi o linie sol = 0; for (i=1;i<=n;i++){ elem = 0; st[0] = 0; for (j=1;j<=m;j++){ while (elem && jos[i][st[elem]] >= jos[i][j]){ elem--; } st[++elem] = j; /// st[elem-1] = primul mai mic /// j are influenta in intervalul st[elem-1] + 1 .. st[elem] len = st[elem] - st[elem-1]; s[i][j] = (long long)(jos[i][j] * (jos[i][j] + 1) / 2) * (len * (len+1) / 2); s[i][j] += len * dp[i][st[elem-1]] + s[i][st[elem-1]]; sol+=s[i][j]; /// dp[i][j] = suma h urilor folosite de la j in stanga /// s[i][j] = simplu dp[i][j] = (long long)(jos[i][j] * (jos[i][j] + 1) / 2) * len + dp[i][st[elem-1]]; } //printf ("%lld\n",sol); } fprintf (fout,"%lld",sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 7288 KB | Output is correct |
2 | Correct | 14 ms | 7288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 7288 KB | Output is correct |
2 | Correct | 10 ms | 7448 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 5752 KB | Output is correct |
2 | Correct | 10 ms | 7280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 37032 KB | Output is correct |
2 | Correct | 126 ms | 74084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 125 ms | 63528 KB | Output is correct |
2 | Correct | 189 ms | 95240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 73 ms | 41020 KB | Output is correct |
2 | Correct | 135 ms | 78772 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 35940 KB | Output is correct |
2 | Correct | 142 ms | 91116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 162 ms | 89576 KB | Output is correct |
2 | Correct | 203 ms | 98612 KB | Output is correct |