Submission #160664

#TimeUsernameProblemLanguageResultExecution timeMemory
160664mraronStrah (COCI18_strah)C++14
110 / 110
205 ms74872 KiB
/* ID: noszaly1 TASK: {TASK} LANG: C++11 */ //Noszály Áron 10o Debreceni Fazekas Mihály Gimnázium #include<iostream> #include<vector> #include<map> #include<set> #include<cassert> #include<cassert> #include<unordered_map> #include<unordered_set> #include<functional> #include<queue> #include<stack> #include<cstring> #include<algorithm> #include<cmath> #include<sstream> #include<iomanip> #include<cstdio> #include<cstdlib> #include<numeric> using namespace std; #define all(x) (x).begin(), (x).end() #define pb push_back #define xx first #define yy second #define sz(x) (int)(x).size() #define gc getchar #define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define mp make_pair typedef long long ll; typedef unsigned long long ull; typedef long double ld; const double PI=acos(-1); template<typename T> T getint() { T val=0; char c; bool neg=false; while((c=gc()) && !(c>='0' && c<='9')) { neg|=c=='-'; } do { val=(val*10)+c-'0'; } while((c=gc()) && (c>='0' && c<='9')); return val*(neg?-1:1); } #define int ll string t[2002]; int d[2002][2002]; int ans[2002][2002]; main() { IO; int n,m; cin>>n>>m; for(int i=0;i<n;++i) { string akt; cin>>akt; t[i]="#"; t[i]+=akt; t[i]+="#"; } for(int i=0;i<n;++i) { for(int j=0;j<=m+1;++j) { if(i==0) { if(t[i][j]=='.') d[i][j]=1; }else { if(t[i][j]=='#') d[i][j]=0; else d[i][j]=d[i-1][j]+1; } } } /*for(int i=0;i<n;++i) { for(int j=0;j<=m+1;++j) { cerr<<d[i][j]<<" "; }cerr<<"\n"; }*/ for(int i=0;i<n;++i) { vector<pair<int,int>> s; for(int j=0;j<=m+1;++j) { #define h xx #define w yy int w=0; while(s.size()>1 && s.back().h>=d[i][j]) { int h=max(s[s.size()-2].h, d[i][j]); w+=s.back().w; ans[h+1][w]++; ans[s.back().h+1][w]--; s.pop_back(); } s.push_back({d[i][j],w+1}); //for(auto i:s) cerr<<i.xx<<":"<<i.yy<<"; "; //cerr<<"\n"; } } for(int i=1;i<=n;++i) { for(int j=1;j<=m;++j) { ans[i+1][j]+=ans[i][j]; } int a=0,b=0; for(int j=m;j>=1;j--) { a+=ans[i][j]; b+=a; ans[i][j]=b; } } int osszans=0; for(int i=1;i<=n;++i) { for(int j=1;j<=m;++j) { osszans+=ans[i][j]*i*j; } } cout<<osszans<<"\n"; return 0; }

Compilation message (stderr)

strah.cpp:64:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#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...