Submission #339501

# Submission time Handle Problem Language Result Execution time Memory
339501 2020-12-25T14:15:31 Z tengiz05 Red-blue table (IZhO19_stones) C++17
0 / 100
45 ms 1516 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1005;
char ans[N][N];
void Solve(){
  int n, m;
  cin >> n >> m;
  bool bad = false;
  if(n > m){
    swap(n, m);
    bad = true;
  }
  int i, j;
  if(n <= 2){
    for(i=0;i<n;i++)
      for(j=0;j<m;j++)ans[i][j] = '-';
  }else if(n <= 4){
    for(i=0;i<(n+2)/2;i++)
      for(j=0;j<m;j++)ans[i][j] = '+';
    for(i=(n+2)/2;i<n;i++)
      for(j=0;j<m;j++)ans[i][j] = '-';
  }else {
    for(i=0;i<n;i++)
      for(j=0;j<m;j++)ans[i][j] = '-';
    int have = 0;
    i=0;
    j=0;
    int need = (n+2)/2;
    while(true){
      if(have == need)i++,have=0;
      if(i == n)break;
      ans[i][j] = '+';
      j++;
      if(j == m)j=0;
      have++;
    }
  }
  if(bad)
    for(i=0;i<n;i++)
      for(j=0;j<m;j++)
        if(ans[i][j] == '+')ans[i][j] = '-';
        else ans[i][j] = '-';

  for(i=0;i<n;i++){
    for(j=0;j<m;j++)
      cout << ans[i][j];
    cout << '\n';
  }
}
signed main(){
  int t;
  cin >> t;
  while(t--)Solve();
  return 0;
}

Compilation message

stones.cpp: In function 'void Solve()':
stones.cpp:39:5: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   39 |   if(bad)
      |     ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Expected integer, but "---" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Expected integer, but "+++++++++++++++++++++++++++++++++++++++++++++" found
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Expected integer, but "---" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 1388 KB Expected integer, but "------------------------------...-------------------------------" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 1516 KB Expected integer, but "+++++++++++++-----------" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Expected integer, but "---" found
2 Halted 0 ms 0 KB -