Submission #162791

#TimeUsernameProblemLanguageResultExecution timeMemory
162791abacabaRed-blue table (IZhO19_stones)C++14
27 / 100
27 ms1964 KiB
#include <chrono> #include <random> #include <iostream> #include <string> #include <unordered_map> #include <cstring> #include <vector> #include <map> #include <set> #include <algorithm> #include <math.h> #include <cstdio> #include <stdio.h> #include <queue> #include <bitset> #include <cstdlib> #include <deque> #include <cassert> #include <stack> using namespace std; #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define endl '\n' #define uset unordered_set #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> const int mod = 1e9 + 7; const int inf = 1e9; const int N = 1e3 + 15; int t, n, m, a[N][N]; int red_in_row[N], red_in_col[N]; inline void make_first_filling() { for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) { if(n >= m) { a[i][j] = 1; ++red_in_row[i]; ++red_in_col[j]; } else a[i][j] = 2; } } main() { scanf("%d", &t); while(t--) { int ans = 0; for(int i = 1; i <= n; ++i) { red_in_row[i] = 0; for(int j = 1; j <= m; ++j) a[i][j] = red_in_col[j] = 0; } scanf("%d %d", &n, &m); make_first_filling(); if(n < m) { for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) if(2 * (red_in_col[j] + 1) < n && 2 * red_in_row[i] <= m) { a[i][j] = 1; red_in_col[j]++; red_in_row[i]++; } } else { for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) if(2 * red_in_col[j] >= n && 2 * (red_in_row[i] - 1) > m) { a[i][j] = 2; red_in_col[j]--; red_in_row[i]--; } } for(int i = 1; i <= n; ++i) ans += (2 * red_in_row[i] > m); for(int j = 1; j <= m; ++j) ans += (2 * red_in_col[j] < n); printf("%d\n", ans); for(int i = 1; i <= n; ++i, puts("")) for(int j = 1; j <= m; ++j) putchar(a[i][j] == 1 ? '+' : '-'); } return 0; }

Compilation message (stderr)

stones.cpp:58:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
stones.cpp: In function 'int main()':
stones.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ~~~~~^~~~~~~~~~
stones.cpp:67:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &n, &m);
         ~~~~~^~~~~~~~~~~~~~~~~
#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...