Submission #200554

#TimeUsernameProblemLanguageResultExecution timeMemory
200554KalamBob (COCI14_bob)C++11
120 / 120
207 ms18424 KiB
// KALAM # include<bits/stdc++.h> # define debug(x) cerr << #x << " = " << x << endl using namespace std; const int N = 1000 + 77; int n , m , a[N][N] , up[N][N] , c[N]; int cur , f[N] , L[N] , R[N]; long long A; inline void Calc() { f[0] = f[cur + 1] = 0; for(int i = 1;i <= cur;++ i) { L[i] = i - 1; while(f[L[i]] >= f[i]) L[i] = L[L[i]]; } for(int i = cur;i > 0;-- i) { R[i] = i + 1; while(f[R[i]] > f[i]) R[i] = R[R[i]]; A += 1ll * (i - L[i]) * (R[i] - i) * f[i]; } cur = 0; } int main() { scanf("%d %d" , & n , & m); for(int i = 1;i <= n;++ i) { for(int j = 1;j <= m;++ j) scanf("%d" , & a[i][j]) , up[i][j] = (a[i][j] == a[i - 1][j] ? up[i - 1][j] : i - 1) , c[j] = i - up[i][j]; f[++ cur] = c[1]; for(int j = 2;j <= m;++ j) { if(a[i][j] != a[i][j - 1]) Calc(); f[++ cur] = c[j]; } Calc(); } printf("%lld\n" , A); return 0; }

Compilation message (stderr)

bob.cpp: In function 'int main()':
bob.cpp:28:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d" , & n , & m);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
bob.cpp:31:95: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
          scanf("%d" , & a[i][j]) , up[i][j] = (a[i][j] == a[i - 1][j] ? up[i - 1][j] : i - 1) , c[j] = i - up[i][j];
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...