Submission #00009
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #include <bits/stdc++.h> using namespace std; #define __ <<" "<< #define ___ <<" " #define bash push_back #define ALL(x) x.begin(),x.end() //#define int long long // struct IoSetup { // IoSetup() { // cin.tie(0); // ios::sync_with_stdio(false); // cout << fixed << setprecision(10); // cerr << fixed << setprecision(10); // } // }IoSetup; typedef long long ll; typedef pair < int , int > pii; static const signed int INF = 0x3f3f3f3f; static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL; static const signed int SMOD = 1000000007; static const signed int NMOD = 998244353; static const signed int dx[]={1,0,-1,0,1,1,-1,-1}; static const signed int dy[]={0,-1,0,1,-1,1,-1,1}; bool inside( int x, int y, int w, int h){ return (x>=0 && y>=0 && x<w && y<h);} template < class T> bool chmax(T &a, const T&b){ if (a<b) return (a=b,1); return 0;} template < class T> bool chmin(T &a, const T&b){ if (b<a) return (a=b,1); return 0;} int m, n; string mas[1010]; int mem[1010][1010]; string s[3]; int near( int i, int j) { int ret = 0; ret += mas[i][j]==s[0][0]; ret += mas[i][j+1]==s[0][1]; ret += mas[i+1][j]==s[1][0]; ret += mas[i+1][j+1]==s[1][1]; return ret; } signed main() { cin >> m >> n; for ( int i = 0; i < m; i++) { cin >> mas[i]; } cin >> s[0]; cin >> s[1]; int ans = 0; for ( int i = 0; i < m-1; i++) { for ( int j = 0; j < n-1; j++) { if (near(i,j)==4) { mem[i][j]++; ans++; } } } int maxi = ans; for ( int i = 0; i < m; i++) { for ( int j = 0; j < n; j++) { int J = 0, O = 0, I = 0, t = 0; if (inside(i,j,m,n) && mas[i+1][j+1]==s[1][1] && mas[i][j+1]==s[0][1]&& mas[i+1][j]==s[1][0] ) { if (s[0][0]== 'J' ){ J++;} if (s[0][0]== 'O' ){ O++;} if (s[0][0]== 'I' ){ I++;} if (s[0][0]==mas[i][j]) t++; } if (inside(i-1,j,m,n) && mas[i-1][j]==s[0][0] && mas[i-1][j+1]==s[0][1] && mas[i][j+1]==s[1][1]) { if (s[1][0]== 'J' ){ J++;} if (s[1][0]== 'O' ){ O++;} if (s[1][0]== 'I' ){ I++;} if (s[1][0]==mas[i][j]) t++; } if (inside(i-1,j-1,m,n) && mas[i-1][j-1]==s[0][0] && mas[i-1][j]==s[0][1] && mas[i][j-1]==s[1][0]) { if (s[1][1]== 'J' ){ J++;} if (s[1][1]== 'O' ){ O++;} if (s[1][1]== 'I' ){ I++;} if (s[1][1]==mas[i][j]) t++; } if (inside(i,j-1,m,n) && mas[i][j-1]==s[0][0] && mas[i+1][j-1]==s[1][0] && mas[i+1][j]==s[1][1]) { if (s[0][1]== 'J' ){ J++;} if (s[0][1]== 'O' ){ O++;} if (s[0][1]== 'I' ){ I++;} if (s[0][1]==mas[i][j]) t++; } int tmp = max(max(J,O),I) - t; chmax(maxi,ans+tmp); } } cout << maxi << endl; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0002 - JOI紋章 |
ユーザー名 | ei1821 |
投稿日時 | 2019-12-16 18:02:49 |
言語 | C++14 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 2753 Byte |
最大実行時間 | 69 ms |
最大メモリ使用量 | 6640 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | INPUT1 | 30 / 30 | sample-*, 01-* |
2 | INPUT2 | 70 / 70 | sample-*, 01-*, 02-* |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |
---|---|---|---|---|---|
01-01.txt | AC | 24 ms | 476 KB |
1
|
2
|
01-02.txt | AC | 19 ms | 404 KB |
1
|
2
|
01-03.txt | AC | 19 ms | 464 KB |
1
|
2
|
01-04.txt | AC | 22 ms | 532 KB |
1
|
2
|
01-05.txt | AC | 25 ms | 596 KB |
1
|
2
|
01-06.txt | AC | 15 ms | 516 KB |
1
|
2
|
01-07.txt | AC | 22 ms | 584 KB |
1
|
2
|
01-08.txt | AC | 18 ms | 652 KB |
1
|
2
|
01-09.txt | AC | 25 ms | 584 KB |
1
|
2
|
01-10.txt | AC | 20 ms | 512 KB |
1
|
2
|
01-11.txt | AC | 20 ms | 708 KB |
1
|
2
|
01-12.txt | AC | 17 ms | 644 KB |
1
|
2
|
01-13.txt | AC | 24 ms | 576 KB |
1
|
2
|
01-14.txt | AC | 22 ms | 632 KB |
1
|
2
|
01-15.txt | AC | 27 ms | 644 KB |
1
|
2
|
01-16.txt | AC | 24 ms | 648 KB |
1
|
2
|
01-17.txt | AC | 17 ms | 644 KB |
1
|
2
|
01-18.txt | AC | 19 ms | 532 KB |
1
|
2
|
01-19.txt | AC | 21 ms | 564 KB |
1
|
2
|
01-20.txt | AC | 18 ms | 536 KB |
1
|
2
|
01-21.txt | AC | 29 ms | 848 KB |
1
|
2
|
01-22.txt | AC | 27 ms | 856 KB |
1
|
2
|
02-01.txt | AC | 20 ms | 556 KB |
2
|
|
02-02.txt | AC | 17 ms | 624 KB |
2
|
|
02-03.txt | AC | 17 ms | 556 KB |
2
|
|
02-04.txt | AC | 24 ms | 604 KB |
2
|
|
02-05.txt | AC | 16 ms | 652 KB |
2
|
|
02-06.txt | AC | 20 ms | 748 KB |
2
|
|
02-07.txt | AC | 23 ms | 880 KB |
2
|
|
02-08.txt | AC | 20 ms | 624 KB |
2
|
|
02-09.txt | AC | 21 ms | 928 KB |
2
|
|
02-10.txt | AC | 18 ms | 956 KB |
2
|
|
02-11.txt | AC | 17 ms | 964 KB |
2
|
|
02-12.txt | AC | 18 ms | 752 KB |
2
|
|
02-13.txt | AC | 15 ms | 688 KB |
2
|
|
02-14.txt | AC | 23 ms | 1140 KB |
2
|
|
02-15.txt | AC | 21 ms | 800 KB |
2
|
|
02-16.txt | AC | 22 ms | 1456 KB |
2
|
|
02-17.txt | AC | 20 ms | 1584 KB |
2
|
|
02-18.txt | AC | 25 ms | 1452 KB |
2
|
|
02-19.txt | AC | 52 ms | 2656 KB |
2
|
|
02-20.txt | AC | 68 ms | 6460 KB |
2
|
|
02-21.txt | AC | 62 ms | 6456 KB |
2
|
|
02-22.txt | AC | 57 ms | 2604 KB |
2
|
|
02-23.txt | AC | 57 ms | 6532 KB |
2
|
|
02-24.txt | AC | 67 ms | 6400 KB |
2
|
|
02-25.txt | AC | 47 ms | 3956 KB |
2
|
|
02-26.txt | AC | 55 ms | 2576 KB |
2
|
|
02-27.txt | AC | 69 ms | 6640 KB |
2
|
|
02-28.txt | AC | 67 ms | 6504 KB |
2
|
|
sample-01.txt | AC | 21 ms | 736 KB |
1
|
2
|
sample-02.txt | AC | 27 ms | 796 KB |
1
|
2
|
sample-03.txt | AC | 28 ms | 856 KB |
1
|
2
|