답안 #119404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119404 2019-06-21T07:40:05 Z ryansee Strah (COCI18_strah) C++14
컴파일 오류
0 ms 0 KB
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF 5000//((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll /*long long*/ int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <short,short> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
int n,m,A[2002],dp[2002],mxelem[2002]; int p[3002];long long ans; char grid[2002][2002];
bool gg[2002];
stack<pi>stk;
ll nC2(ll n){return (long long)n*(n+1)/2; }
int main(){
	FAST
	cin>>n>>m;
	FOR(i,0,n)FOR(j,0,m)cin>>grid[i][j];
	FOR(i,1,3001)p[i]=p[i-1]+(i*(i-1));
	FOR(ii,0,n){
		FOR(j,0,m){
			if(grid[ii][j]=='#')A[j]=0;
			else A[j]++;
		}
		mmst(dp,0); mmst(gg,0); mmst(mxelem,0); //vector<ll>start[2002],endd[2002]; //FOR(j,1,m)if(A[j-1]==A[j])gg[j]=1;
		while(stk.size())stk.pop();
		stk.emplace(-LLINF,-1);
		FOR(j,0,m){
			if(!gg[j]){
				while(stk.size()&&stk.top().f>=A[j]){
					if(stk.top().f==A[j]){gg[j]=1;break;}stk.pop();
				}
				if(!gg[j]){
				mxelem[j]=max(mxelem[j],stk.top().f); dp[j]=j-stk.top().s; //start[stk.top().s+1].pb(A[j]);endd[j].pb(A[j]);
				}
			}stk.emplace(A[j],j);
		}
		while(stk.size())stk.pop();
		stk.emplace(-LLINF,m);
		for(ll j=m-1;j>=0;--j){
			if(!gg[j]){
				while(stk.size()&&stk.top().f>=A[j]){
					stk.pop();
				}
				mxelem[j]=max(mxelem[j],stk.top().f);dp[j]+=stk.top().s-j; //start[j+1].pb(A[j]);endd[stk.top().s].pb(A[j]);
			}stk.emplace(A[j],j);
		}
		// multiset<short>heights;heights.ins(0);
		FOR(j,0,m)if(!gg[j]){
			if(!gg[j]){assert(dp[j]>=2);dp[j]--;}
			// for(auto i:start[j])heights.ins(i);
			// for(auto i:endd[j])heights.erase(heights.find(i));
			// if(gg[j])continue;if(0)cerr<<ii<<' '<<j<<' '<<(nC2(A[j]-*(--heights.end()))*(nC2(dp[j])*dp[j]-p[dp[j]]))<<'\n';
			// cerr<<A[j]<<": "<<(*--heights.end())<<'\n';
			// cerr<<"start: ";for(auto i:start[j])cerr<<i<<' ';cerr<<endl;
			// cerr<<"endd: ";for(auto i:endd[j])cerr<<i<<' ';cerr<<endl;
			ans+=(nC2(A[j])*((long long)nC2(dp[j])*dp[j]-p[dp[j]]))-((long long)nC2(mxelem[j])*(long long)(nC2(dp[j])*dp[j]-p[dp[j]]));
		}
		// cerr<<ans<<'\n';
	}
	cout<<ans;
}
/*
2 3
.#.
..#
* 
* 3 4
..#.
#...
...#
*/ 

Compilation message

strah.cpp: In function 'int main()':
strah.cpp:63:40: error: no matching function for call to 'max(int&, short int&)'
     mxelem[j]=max(mxelem[j],stk.top().f); dp[j]=j-stk.top().s; //start[stk.top().s+1].pb(A[j]);endd[j].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
strah.cpp:63:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
     mxelem[j]=max(mxelem[j],stk.top().f); dp[j]=j-stk.top().s; //start[stk.top().s+1].pb(A[j]);endd[j].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
strah.cpp:63:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
     mxelem[j]=max(mxelem[j],stk.top().f); dp[j]=j-stk.top().s; //start[stk.top().s+1].pb(A[j]);endd[j].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
strah.cpp:63:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     mxelem[j]=max(mxelem[j],stk.top().f); dp[j]=j-stk.top().s; //start[stk.top().s+1].pb(A[j]);endd[j].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
strah.cpp:63:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     mxelem[j]=max(mxelem[j],stk.top().f); dp[j]=j-stk.top().s; //start[stk.top().s+1].pb(A[j]);endd[j].pb(A[j]);
                                        ^
strah.cpp:74:40: error: no matching function for call to 'max(int&, short int&)'
     mxelem[j]=max(mxelem[j],stk.top().f);dp[j]+=stk.top().s-j; //start[j+1].pb(A[j]);endd[stk.top().s].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
strah.cpp:74:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
     mxelem[j]=max(mxelem[j],stk.top().f);dp[j]+=stk.top().s-j; //start[j+1].pb(A[j]);endd[stk.top().s].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
strah.cpp:74:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
     mxelem[j]=max(mxelem[j],stk.top().f);dp[j]+=stk.top().s-j; //start[j+1].pb(A[j]);endd[stk.top().s].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
strah.cpp:74:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     mxelem[j]=max(mxelem[j],stk.top().f);dp[j]+=stk.top().s-j; //start[j+1].pb(A[j]);endd[stk.top().s].pb(A[j]);
                                        ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from strah.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
strah.cpp:74:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     mxelem[j]=max(mxelem[j],stk.top().f);dp[j]+=stk.top().s-j; //start[j+1].pb(A[j]);endd[stk.top().s].pb(A[j]);
                                        ^