답안 #122493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122493 2019-06-28T12:37:28 Z egorlifar Dango Maker (JOI18_dango_maker) C++17
100 / 100
752 ms 171128 KB
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
    
     
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } 
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const pair<T, U> &_p) { _out << _p.first << ' ' << _p.second; return _out; }
template<typename T, typename U> inline istream &operator>> (istream &_in, pair<T, U> &_p) { _in >> _p.first >> _p.second; return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const vector<T> &_v) { if (_v.empty()) { return _out; } _out << _v.front(); for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const unordered_map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
const string FILENAME = "input";
const int MAXN = 3228;

int n, m;
string s[MAXN];
int dp[MAXN][MAXN][4];


int get(int i, int j, int t) {
	if (i < 0 || s[i][j] != 'R') {
		return 0;
	}
	if (dp[i][j][t] != -1) {
		return dp[i][j][t];
	}
	int res = 0;
	chkmax(res, get(i - 1, j + 1, (t * 2) % 4));
	chkmax(res, get(i - 2, j + 2, 0));
	if (s[i][j] == 'R' && s[i + 1][j] == 'G' && s[i + 2][j] == 'W' && t == 0) {
		chkmax(res, get(i - 1, j + 1, 0) + 1);
		chkmax(res, get(i - 2, j + 2, 0) + 1);
	}
	if (s[i][j] == 'R' && s[i][j + 1] == 'G' && s[i][j + 2] == 'W') {
		chkmax(res, get(i - 1, j + 1, (t * 2 + 1) % 4) + 1);
		chkmax(res, get(i - 2, j + 2, 2) + 1);
	}
	dp[i][j][t] = res;
	return res;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//read(FILENAME);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i <= n + 2; i++) {
		for (int j = 0; j <= m + 2; j++) {
			for (int k = 0; k < 4; k++) {
				dp[i][j][k] = -1;
			}
		}
	}
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = m - 1; j >= 0; j--) {
			if (dp[i][j][0] == -1) {
				ans += get(i, j, 0);
			}
		}
	}
	cout << ans << '\n';
	return 0; 		
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 3 ms 512 KB Output is correct
38 Correct 2 ms 512 KB Output is correct
39 Correct 2 ms 512 KB Output is correct
40 Correct 2 ms 512 KB Output is correct
41 Correct 3 ms 512 KB Output is correct
42 Correct 2 ms 512 KB Output is correct
43 Correct 2 ms 512 KB Output is correct
44 Correct 2 ms 512 KB Output is correct
45 Correct 2 ms 512 KB Output is correct
46 Correct 2 ms 512 KB Output is correct
47 Correct 2 ms 640 KB Output is correct
48 Correct 2 ms 512 KB Output is correct
49 Correct 2 ms 512 KB Output is correct
50 Correct 3 ms 512 KB Output is correct
51 Correct 2 ms 512 KB Output is correct
52 Correct 3 ms 512 KB Output is correct
53 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 3 ms 512 KB Output is correct
38 Correct 2 ms 512 KB Output is correct
39 Correct 2 ms 512 KB Output is correct
40 Correct 2 ms 512 KB Output is correct
41 Correct 3 ms 512 KB Output is correct
42 Correct 2 ms 512 KB Output is correct
43 Correct 2 ms 512 KB Output is correct
44 Correct 2 ms 512 KB Output is correct
45 Correct 2 ms 512 KB Output is correct
46 Correct 2 ms 512 KB Output is correct
47 Correct 2 ms 640 KB Output is correct
48 Correct 2 ms 512 KB Output is correct
49 Correct 2 ms 512 KB Output is correct
50 Correct 3 ms 512 KB Output is correct
51 Correct 2 ms 512 KB Output is correct
52 Correct 3 ms 512 KB Output is correct
53 Correct 2 ms 512 KB Output is correct
54 Correct 2 ms 640 KB Output is correct
55 Correct 11 ms 12928 KB Output is correct
56 Correct 4 ms 896 KB Output is correct
57 Correct 9 ms 9088 KB Output is correct
58 Correct 46 ms 22272 KB Output is correct
59 Correct 363 ms 170804 KB Output is correct
60 Correct 373 ms 170744 KB Output is correct
61 Correct 370 ms 170844 KB Output is correct
62 Correct 3 ms 640 KB Output is correct
63 Correct 386 ms 167004 KB Output is correct
64 Correct 747 ms 171056 KB Output is correct
65 Correct 752 ms 170972 KB Output is correct
66 Correct 725 ms 171128 KB Output is correct
67 Correct 278 ms 170680 KB Output is correct
68 Correct 237 ms 170744 KB Output is correct
69 Correct 250 ms 170744 KB Output is correct
70 Correct 74 ms 22392 KB Output is correct
71 Correct 73 ms 22400 KB Output is correct
72 Correct 72 ms 22400 KB Output is correct
73 Correct 75 ms 22520 KB Output is correct
74 Correct 73 ms 22392 KB Output is correct
75 Correct 76 ms 22396 KB Output is correct
76 Correct 72 ms 22520 KB Output is correct
77 Correct 76 ms 22400 KB Output is correct
78 Correct 77 ms 22392 KB Output is correct
79 Correct 77 ms 22392 KB Output is correct
80 Correct 75 ms 22392 KB Output is correct
81 Correct 74 ms 22392 KB Output is correct
82 Correct 72 ms 22520 KB Output is correct
83 Correct 73 ms 22528 KB Output is correct
84 Correct 80 ms 22392 KB Output is correct
85 Correct 81 ms 22648 KB Output is correct
86 Correct 78 ms 22400 KB Output is correct
87 Correct 89 ms 22424 KB Output is correct
88 Correct 74 ms 22392 KB Output is correct
89 Correct 78 ms 22400 KB Output is correct
90 Correct 79 ms 22400 KB Output is correct