제출 #151245

#제출 시각아이디문제언어결과실행 시간메모리
151245Ruxandra985Strah (COCI18_strah)C++14
110 / 110
203 ms98612 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

strah.cpp: In function 'int main()':
strah.cpp:13:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d%d",&n,&m);
     ~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...