Submission #3766806
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<int(n); i++) #define FOR(i,m,n) for(int i=int(m); i<int(n); i++) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VLL vector<long long> #define VVI vector<vector<int>> #define VVLL vector<vector<long long>> #define VC vector<char> #define VS vector<string> #define VVS vector<vector<string>> #define VVC vector<vector<char>> #define fore(i,a) for(auto &i:a) typedef long long ll; typedef pair <int, int> P; const int INF = 2147483647; const ll INFL = 9223372036854775807; const ll mod = 1000000007; using namespace std; int main() { int h, w; cin >> h >> w; VI v(26, 0); REP(i, h*w) { char c; cin >> c; v[c - 'a']++; } bool b = true; if (h == 1 || w == 1) { if ((h + w) % 2) { REP(i, 26) { if (v[i] % 2)b = false; } } else { bool c = true; REP(i, 26) { if (v[i] % 2) { if (c)c = false; else b = false; } } } } else if (h % 2 == 0 && w % 2 == 0) { REP(i, 26) { if (v[i] % 4)b = false; } } else if (h % 2 == 1 && w % 2 == 0) { int d = 0, e = 0; REP(i, 26) { if (v[i] % 2 == 0) { d += v[i] / 4; e += v[i] % 4 / 2; } else b = false; } if (d - w * (h - 1) / 4 < 0) b = false; } else if(h % 2 == 1 && w % 2 == 0) { int d = 0, e = 0; REP(i, 26) { if (v[i] % 2 == 0) { d += v[i] / 4; e += v[i] % 4 / 2; } else b = false; } if (d - h * (w - 1) / 4 < 0) b = false; } else { int d, e, f; d = e = f = 0; REP(i, 26) { if (v[i] % 2 == 0) { d += v[i] / 4; e += v[i] % 4 / 2; } else if (f == 0) { f = 1; v[i]--; d += v[i] / 4; e += v[i] % 4 / 2; } if ((w - 1)*(h - 1) / 4 > d) { b = false; } if (f == 0)b = false; } } if (b)cout << "Yes" << endl; else cout << "No" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Palindromic Matrix |
User | toku |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1965 Byte |
Status | WA |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
0_04.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 1 ms | 256 KB |
1_09.txt | AC | 2 ms | 256 KB |
1_10.txt | AC | 2 ms | 256 KB |
1_11.txt | AC | 2 ms | 256 KB |
1_12.txt | AC | 2 ms | 256 KB |
1_13.txt | AC | 2 ms | 256 KB |
1_14.txt | AC | 2 ms | 256 KB |
1_15.txt | AC | 1 ms | 256 KB |
1_16.txt | AC | 2 ms | 256 KB |
1_17.txt | AC | 2 ms | 256 KB |
1_18.txt | WA | 1 ms | 256 KB |
1_19.txt | AC | 1 ms | 256 KB |
1_20.txt | AC | 1 ms | 256 KB |
1_21.txt | WA | 1 ms | 256 KB |
1_22.txt | AC | 1 ms | 256 KB |
1_23.txt | AC | 1 ms | 256 KB |
1_24.txt | WA | 1 ms | 256 KB |
1_25.txt | AC | 1 ms | 256 KB |
1_26.txt | AC | 1 ms | 256 KB |