Submission #684514

#TimeUsernameProblemLanguageResultExecution timeMemory
684514Chal1shkanRed-blue table (IZhO19_stones)C++14
27 / 100
39 ms1552 KiB
# include <bits/stdc++.h> # define pb push_back # define ff first # define ss second # define nl "\n" # define sz(x) ((int)(x).size()) typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll maxn = 5e5 + 25; const ll inf = 1e18 + 0; const ll mod = 1e9 + 7; const ll dx[] = {-1, 1, 0, 0}; const ll dy[] = {0, 0, -1, 1}; using namespace std; int n, m; int cnt (vector < vector <int> >& a) { int res = 0; for (int i = 0; i < n; ++i) { int cnt[2] = {0}; for (int j = 0; j < m; ++j) { cnt[a[i][j]]++; } if (cnt[1] >= m / 2 + 1) { res++; } } for (int j = 0; j < m; ++j) { int cnt[2] = {0}; for (int i = 0; i < n; ++i) { cnt[a[i][j]]++; } if (cnt[0] >= n / 2 + 1) { res++; } } return res; } void print (vector < vector <int> > a) { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (a[i][j] == 0) cout << '-'; else cout << '+'; } cout << nl; } cout << nl; } void ma1n (/* SABR */) { cin >> n >> m; if (n >= m) { vector < vector <int> > a(n, vector <int>(m, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (j < m / 2 + 1) { a[i][j] = 1; } else { a[i][j] = 0; } } } cout << cnt(a) << nl; print(a); } else { vector < vector <int> > a(n, vector <int>(m, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (i < n / 2 + 1) { a[i][j] = 0; } else { a[i][j] = 1; } } } cout << cnt(a) << nl; print(a); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); int ttt = 1; cin >> ttt; for (int test = 1; test <= ttt; ++test) { // cout << "Case " << test << ":" << ' '; ma1n(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...