Submission #167946

#TimeUsernameProblemLanguageResultExecution timeMemory
167946YottaByteRed-blue table (IZhO19_stones)C++14
Compilation error
0 ms0 KiB
#include <iostream> using namespace std; #define ll long long #define sz(x) (int)x.size() #define pii pair < int, int > #define endl "\n" #define METH ios::sync_with_stdio(0); cin.tie(0); #define BEGIN cout << "BEGIN" << endl; #define END cout << "END" << endl; const int mod = 1e9 + 7; /// ANOTHER HASH MOD: 228228227 const int prime = 29; /// ANOTHER HASH PRIME: 997 const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8); int n, m; inline void purify() { } inline void precalc() { } inline void read() { scanf("%d %d", &n, &m); } inline int check(int mask) { int res = 0; for (int i = 0; i < n; i++) { int cnta = 0; for (int j = 0; j < m; j++) { if (mask >> (j + i * m) & 1) { cnta++; } } if (cnta > m / 2) { res++; } } for (int i = 0; i < m; i++) { int cntb = 0; for (int j = 0; i + j < m * n; j += m) { if (!(mask >> (j + i) & 1)) { cntb++; } } if (cntb > n / 2) { res++; } } return res; } void out(int mask) { for (int i = 0; i < n * m; i++) { if (mask >> i & 1) { cout << '+'; } else { cout << '-'; } if ((i + 1) % m == 0) { cout << endl; } } } inline void solve() { if (n * m > 20) { break; } int ansab = 0, ans = -1; for (int i = 0; i < (1 << (n * m)); i++) { if (ansab < check(i)) { ansab = check(i); ans = i; } } cout << ansab << endl; out(ans); } int main() { int t; scanf("%d", &t); //precalc(); while (t--) { //purify(); read(); solve(); } }

Compilation message (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:75:7: error: break statement not within loop or switch
       break;
       ^~~~~
stones.cpp: In function 'int main()':
stones.cpp:91:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &t);
  ~~~~~^~~~~~~~~~
stones.cpp: In function 'void read()':
stones.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~