답안 #165553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165553 2019-11-27T12:39:39 Z Sensei Strah (COCI18_strah) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e3;

char a[MAXN + 7][MAXN + 7];

long long n[MAXN + 7][MAXN + 7];
long long ne[MAXN + 7][MAXN + 7];
long long e[MAXN + 7][MAXN + 7];
long long se[MAXN + 7][MAXN + 7];
long long s[MAXN + 7][MAXN + 7];
long long sw[MAXN + 7][MAXN + 7];
long long w[MAXN + 7][MAXN + 7];
long long nw[MAXN + 7][MAXN + 7];

// int mat[MAXN + 7][MAXN + 7];

#define dbg(x) cerr<<#x<<" : "<<x<<" "

int main () {
	int N, M;

	scanf("%d %d", &N, &M);

	for (int i = 1; i <= N; i++) {
		scanf("\n");
		for (int j = 1; j <= M; j++) {
			scanf("%c", &a[i][j]);
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (a[i][j] != '.') {
				continue;
			}

			if (a[i - 1][j] == '.') {
				n[i][j] = 1 + n[i - 1][j];
			}
			else {
				n[i][j] = 1;
			}

			if (a[i][j - 1] == '.') {
				w[i][j] = 1 + w[i][j - 1];
			}
			else {
				w[i][j] = 1;
			}
		}

		for (int j = M; j >= 1; j--) {
			if (a[i][j] != '.') {
				continue;
			}

			if (a[i][j + 1] == '.') {
				e[i][j] = 1 + e[i][j + 1];
			}
			else {
				e[i][j] = 1;
			}
		}
	}

	for (int i = N; i >= 1; i--) {
		for (int j = 1; j <= M; j++) {
			if (a[i][j] != '.') {
				continue;
			}

			if (a[i + 1][j] == '.') {
				s[i][j] = 1 + s[i + 1][j];
			}
			else {
				s[i][j] = 1;
			}
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (a[i][j] == '.') {
				nw[i][j] = 1 + max(0, nw[i - 1][j] + nw[i][j - 1] - nw[i - 1][j - 1]);
			}
		}

		for (int j = M; j >= 1; j--) {
			if (a[i][j] == '.') {
				ne[i][j] = 1 + max(0, ne[i - 1][j] + ne[i][j + 1] - ne[i - 1][j + 1]);
			}
		}
	}

	for (int i = N; i >= 1; i--) {
		for (int j = 1; j <= M; j++) {
			if (a[i][j] == '.') {
				sw[i][j] = 1 + max(0, sw[i + 1][j] + sw[i][j - 1] - sw[i + 1][j - 1]);
			}
		}

		for (int j = M; j >= 1; j--) {
			if (a[i][j] == '.') {
				se[i][j] = 1 + max(0, se[i + 1][j] + se[i][j + 1] - se[i + 1][j + 1]);
			}
		}
	}

	long long ans = 0;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (a[i][j] != '.') {
				continue;
			}

			// dbg(i);dbg(j);

			// mat[i][j] = mat[i - 1][j] + mat[i][j - 1] - mat[i - 1][j - 1] + n[i][j] + w[i][j] - 1;

			// dbg(mat[i][j]);
			// cerr << "\n";

			// ans += mat[i][j];

			// dbg(i);dbg(j);
			// cerr << "\n";
			// dbg(n[i][j]);dbg(e[i][j]);dbg(s[i][j]);dbg(w[i][j]);
			// cerr << "\n";
			// dbg(ne[i][j]);dbg(se[i][j]);dbg(sw[i][j]);dbg(nw[i][j]);
			// cerr << "\n";

			ans += nw[i][j] * ne[i][j] * se[i][j] * sw[i][j]
					/ (
					n[i][j] * e[i][j] * s[i][j] * w[i][j]
					)
					// + 1;
					;
		}
	}

	cout << ans << "\n";

	return 0;
}

Compilation message

strah.cpp: In function 'int main()':
strah.cpp:87:73: error: no matching function for call to 'max(int, long long int)'
     nw[i][j] = 1 + max(0, nw[i - 1][j] + nw[i][j - 1] - nw[i - 1][j - 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:87:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     nw[i][j] = 1 + max(0, nw[i - 1][j] + nw[i][j - 1] - nw[i - 1][j - 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:87:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     nw[i][j] = 1 + max(0, nw[i - 1][j] + nw[i][j - 1] - nw[i - 1][j - 1]);
                                                                         ^
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:1:
/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:87:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     nw[i][j] = 1 + max(0, nw[i - 1][j] + nw[i][j - 1] - nw[i - 1][j - 1]);
                                                                         ^
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:1:
/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:87:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     nw[i][j] = 1 + max(0, nw[i - 1][j] + nw[i][j - 1] - nw[i - 1][j - 1]);
                                                                         ^
strah.cpp:93:73: error: no matching function for call to 'max(int, long long int)'
     ne[i][j] = 1 + max(0, ne[i - 1][j] + ne[i][j + 1] - ne[i - 1][j + 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:93:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     ne[i][j] = 1 + max(0, ne[i - 1][j] + ne[i][j + 1] - ne[i - 1][j + 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:93:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     ne[i][j] = 1 + max(0, ne[i - 1][j] + ne[i][j + 1] - ne[i - 1][j + 1]);
                                                                         ^
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:1:
/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:93:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     ne[i][j] = 1 + max(0, ne[i - 1][j] + ne[i][j + 1] - ne[i - 1][j + 1]);
                                                                         ^
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:1:
/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:93:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     ne[i][j] = 1 + max(0, ne[i - 1][j] + ne[i][j + 1] - ne[i - 1][j + 1]);
                                                                         ^
strah.cpp:101:73: error: no matching function for call to 'max(int, long long int)'
     sw[i][j] = 1 + max(0, sw[i + 1][j] + sw[i][j - 1] - sw[i + 1][j - 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:101:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     sw[i][j] = 1 + max(0, sw[i + 1][j] + sw[i][j - 1] - sw[i + 1][j - 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:101:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     sw[i][j] = 1 + max(0, sw[i + 1][j] + sw[i][j - 1] - sw[i + 1][j - 1]);
                                                                         ^
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:1:
/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:101:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     sw[i][j] = 1 + max(0, sw[i + 1][j] + sw[i][j - 1] - sw[i + 1][j - 1]);
                                                                         ^
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:1:
/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:101:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     sw[i][j] = 1 + max(0, sw[i + 1][j] + sw[i][j - 1] - sw[i + 1][j - 1]);
                                                                         ^
strah.cpp:107:73: error: no matching function for call to 'max(int, long long int)'
     se[i][j] = 1 + max(0, se[i + 1][j] + se[i][j + 1] - se[i + 1][j + 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:107:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     se[i][j] = 1 + max(0, se[i + 1][j] + se[i][j + 1] - se[i + 1][j + 1]);
                                                                         ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from strah.cpp:1:
/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:107:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     se[i][j] = 1 + max(0, se[i + 1][j] + se[i][j + 1] - se[i + 1][j + 1]);
                                                                         ^
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:1:
/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:107:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     se[i][j] = 1 + max(0, se[i + 1][j] + se[i][j + 1] - se[i + 1][j + 1]);
                                                                         ^
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:1:
/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:107:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     se[i][j] = 1 + max(0, se[i + 1][j] + se[i][j + 1] - se[i + 1][j + 1]);
                                                                         ^
strah.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~~
strah.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\n");
   ~~~~~^~~~~~
strah.cpp:30:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%c", &a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~