답안 #311797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
311797 2020-10-11T18:10:07 Z Valera_Grinenko Red-blue table (IZhO19_stones) C++17
27 / 100
78 ms 1404 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
  int n = 0, m = 0;
  cin >> n >> m;
  if(n == 1) {
    cout << m << endl;
    for(int i = 0; i < m; i++) cout << '-';
    cout << endl;
  } else if(m == 1) {
    cout << n << endl;
    for(int i = 0; i < n; i++) cout << "+\n";
  } else {
    vector<vector<char> > ans(n, vector<char>(m));
    int ansval = 0;
    if(n > m) {
      for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
          ans[i][j] = '+';
      int change = (m - 1) / 2;
      ansval = n + change;
      for(int i = 0; i < n; i++)
        for(int j = 0; j < change; j++)
          ans[i][j] = '-';
    } else {
      for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
          ans[i][j] = '-';
      int change = (n - 1) / 2;
      ansval = m + change;
      for(int i = 0; i < change; i++)
        for(int j = 0; j < m; j++)
          ans[i][j] = '+';
    }
    cout << ansval << endl;
    for(auto& x : ans) {
      for(auto& c : x) cout << c;
      cout << endl;
    }
  }
}
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int t = 0;

  cin >> t;

  while(t--) solve();

  return 0;
}
/*

*/

Compilation message

stones.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 8 ms 292 KB Output is correct
4 Incorrect 16 ms 412 KB Wrong answer in test 5 29: 31 < 32
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 1404 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 1400 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 8 ms 292 KB Output is correct
4 Incorrect 16 ms 412 KB Wrong answer in test 5 29: 31 < 32