답안 #527725

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527725 2022-02-18T05:46:12 Z 8e7 Sandcastle 2 (JOI22_ho_t5) C++17
10 / 100
3 ms 716 KB
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 105
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
int a[maxn][maxn];
int main() {
	io
	int n, m;
	cin >> n >> m;
	vector<int> val;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) {
			cin >> a[i][j];
			val.push_back(a[i][j]);
		}
	}
	sort(val.begin(), val.end());
	val.resize(int(unique(val.begin(), val.end()) - val.begin()));
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) {
			a[i][j] = lower_bound(val.begin(), val.end(), a[i][j]) - val.begin();
		}
	}
	if (n == 1) {
		ll ans = 0, cnt = 0;
		for (int i = 1;i < m;i++) {
			if (a[0][i] > a[0][i-1]) {
				cnt++;
			} else {
				cnt = 0;
			}
			ans += cnt;
		}
		cnt = 0;
		for (int i = m - 2;i >= 0;i--) {
			if (a[0][i] > a[0][i+1]) {
				cnt++;
			} else {
				cnt = 0;
			}
			ans += cnt;
		}
		ans += m;
		cout << ans << endl;
	} else {
		int ans = 0;
		for (int l = 0;l < n;l++) {
			for (int r = l;r < n;r++) {
				for (int u = 0;u < m;u++) {
					for (int d = u;d < m;d++) {
						vector<pair<int, pii> > val;
						for (int x = l;x <= r;x++) {
							for (int y = u;y <= d;y++) {
								val.push_back({a[x][y], make_pair(x, y)});	
							}
						}
						sort(val.begin(), val.end());
						bool poss = 1;
						for (int i = 1;i < val.size();i++) {
							int xd = abs(val[i].ss.ff - val[i-1].ss.ff);
							int yd = abs(val[i].ss.ss - val[i-1].ss.ss);
							if (xd + yd > 1) {
								poss = 0;
								break;
							}
						}
						if (poss) ans++;
					}
				}
			}
		}
		cout << ans << "\n";
	}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:75:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |       for (int i = 1;i < val.size();i++) {
      |                      ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 3 ms 716 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 216 KB Output is correct
7 Runtime error 1 ms 472 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 216 KB Output is correct
7 Runtime error 1 ms 472 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 216 KB Output is correct
7 Runtime error 1 ms 472 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -