Submission #257099

# Submission time Handle Problem Language Result Execution time Memory
257099 2020-08-03T15:29:57 Z BThero Red-blue table (IZhO19_stones) C++17
15 / 100
13 ms 1920 KB
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = (int)1e3 + 5;
const int INF = (int)1e9;

char s[MAXN][MAXN];
int cnt[MAXN];
int n, m;
pii ans;

void solve() {
  scanf("%d %d", &n, &m);
  ans = mp(m, 0);
  
  for (int i = 0; i < m; ++i) {
    cnt[i] = n;
  }
  
  for (int step = 1, ptr = 0, col = m; step <= n; ++step) {
    for (int i = 1; i <= m / 2 + 1; ++i) {
      if (--cnt[ptr] < n / 2 + 1) {
        --col;
      }
      
      ptr = (ptr + 1) % m;
    }
    
    ans = max(ans, mp(step + col, step));
  } 
  
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      s[i][j] = '-';
    }
    
    s[i][m] = '\0';
  }
  
  for (int step = 1, ptr = 0; step <= ans.se; ++step) {
    for (int i = 1; i <= m / 2 + 1; ++i) {
      s[step - 1][ptr] = '+';
      ptr = (ptr + 1) % m;
    }
  }
  
  printf("%d\n", ans.fi);
  
  for (int i = 0; i < n; ++i) {
    printf("%s\n", s[i]);
  }
}

int main() {
  int tt;
  scanf("%d", &tt);
  
  while (tt--) {
    solve();
  }

  return 0;
}

Compilation message

stones.cpp: In function 'void solve()':
stones.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:69:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &tt);
   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB in the table A+B is not equal to 1
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB in the table A+B is not equal to 1
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB in the table A+B is not equal to 1
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1408 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1536 KB Output is correct
2 Correct 7 ms 1920 KB Output is correct
3 Correct 6 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB in the table A+B is not equal to 1