Submission #2135137


Source Code Expand

/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-2-25 16:28:33
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int X, Y, A, B;
char F[1020][1020];

void flush()
{
  for (auto i = 0; i < X; i++)
  {
    for (auto j = 0; j < Y; j++)
    {
      cout << F[i][j];
    }
    cout << endl;
  }
}

void standard_make()
{
  for (auto i = 0; i + 1 < X; i += 2)
  {
    for (auto j = 0; j + 1 < Y; j += 2)
    {
      if (A > 0)
      {
        F[i][j] = '<';
        F[i][j + 1] = '>';
        A--;
        if (A > 0)
        {
          F[i + 1][j] = '<';
          F[i + 1][j + 1] = '>';
          A--;
        }
      }
      else if (B > 0)
      {
        F[i][j] = '^';
        F[i + 1][j] = 'v';
        B--;
        if (B > 0)
        {
          F[i][j + 1] = '^';
          F[i + 1][j + 1] = 'v';
          B--;
        }
      }
    }
  }
}

void make()
{
  if (X % 2 == 1)
  {
    for (auto j = 0; j + 1 < Y; j += 2)
    {
      if (A > 0)
      {
        F[X-1][j] = '<';
        F[X-1][j + 1] = '>';
        A--;
      }
    }
  }
  if (Y%2 == 1)
  {
    for (auto i = 0; i + 1 < X; i += 2)
    {
    if (B > 0)
      {
        F[i][Y - 1] = '^';
        F[i + 1][Y - 1] = 'v';
        B--;
      }
    }
  }
  standard_make();
  flush();
}

void make2()
{
  if (X%2 == 1)
  {
    for (auto j = 0; j + 1 < Y - 2; j += 2)
    {
      if (A > 0)
      {
        F[X-1][j] = '<';
        F[X-1][j + 1] = '>';
        A--;
      }
    }
  }
  if (Y%2 == 1)
  {
    for (auto i = 0; i + 1 < X - 2; i += 2)
    {
    if (B > 0)
      {
        F[i][Y - 1] = '^';
        F[i + 1][Y - 1] = 'v';
        B--;
      }
    }
  }
  F[X - 3][Y - 3] = '^';
  F[X - 2][Y - 3] = 'v';
  F[X - 3][Y - 2] = '<';
  F[X - 3][Y - 1] = '>';
  F[X - 2][Y - 1] = '^';
  F[X - 1][Y - 1] = 'v';
  F[X - 1][Y - 3] = '<';
  F[X - 1][Y - 2] = '>';
  X -= 2;
  Y -= 2;
  standard_make();
  flush();
}

int main()
{
  fill(&F[0][0], &F[0][0] + 1020 * 1020, '.');
  cin >> X >> Y >> A >> B;
  int S = (X * Y) / 2;
  int SA = X * (Y / 2);
  int SB = (X / 2) * Y;
  if (!(A+B <= S && A <= SA && B <= SB))
  {
    cout << "NO" << endl;
    return 0;
  }
  if (A+B == S && (SA - A) % 2 == 1)
  {
    if ((X * Y) % 2 == 0)
    {
      cout << "NO" << endl;
      return 0;
    } else {
      cout << "YES" << endl;
      make2();
      return 0;
    }
  }
  cout << "YES" << endl;
  make();
}

Submission Info

Submission Time
Task C - Tiling
User kazunetakahashi
Language C++14 (Clang 3.8.0)
Score 0
Code Size 3287 Byte
Status WA
Exec Time 37 ms
Memory 2304 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 96
WA × 6
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt, 68.txt, 69.txt, 70.txt, 71.txt, 72.txt, 73.txt, 74.txt, 75.txt, 76.txt, 77.txt, 78.txt, 79.txt, 80.txt, 81.txt, 82.txt, 83.txt, 84.txt, 85.txt, 86.txt, 87.txt, 88.txt, 89.txt, 90.txt, 91.txt, 92.txt, 93.txt, 94.txt, 95.txt, 96.txt, 97.txt, 98.txt, 99.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 4 ms 1280 KB
02.txt AC 2 ms 1280 KB
03.txt AC 3 ms 1280 KB
04.txt AC 2 ms 1280 KB
05.txt AC 3 ms 1280 KB
06.txt AC 2 ms 1280 KB
07.txt AC 4 ms 1280 KB
08.txt AC 4 ms 1280 KB
09.txt AC 2 ms 1280 KB
10.txt AC 2 ms 1280 KB
11.txt AC 2 ms 1280 KB
12.txt AC 2 ms 1280 KB
13.txt AC 2 ms 1280 KB
14.txt AC 2 ms 1280 KB
15.txt AC 14 ms 1536 KB
16.txt AC 8 ms 1408 KB
17.txt AC 2 ms 1280 KB
18.txt AC 7 ms 1408 KB
19.txt AC 2 ms 1280 KB
20.txt AC 2 ms 1280 KB
21.txt AC 9 ms 1408 KB
22.txt AC 2 ms 1280 KB
23.txt AC 21 ms 1792 KB
24.txt AC 13 ms 1536 KB
25.txt AC 9 ms 1408 KB
26.txt AC 2 ms 1280 KB
27.txt AC 4 ms 1280 KB
28.txt AC 2 ms 1280 KB
29.txt AC 2 ms 1280 KB
30.txt AC 2 ms 1280 KB
31.txt AC 2 ms 1280 KB
32.txt AC 2 ms 1280 KB
33.txt AC 34 ms 2176 KB
34.txt AC 6 ms 1408 KB
35.txt AC 2 ms 1280 KB
36.txt AC 2 ms 1280 KB
37.txt AC 3 ms 1280 KB
38.txt AC 2 ms 1280 KB
39.txt AC 2 ms 1280 KB
40.txt AC 8 ms 1408 KB
41.txt AC 14 ms 1664 KB
42.txt AC 5 ms 1408 KB
43.txt AC 3 ms 1280 KB
44.txt AC 7 ms 1408 KB
45.txt WA 16 ms 1664 KB
46.txt AC 6 ms 1408 KB
47.txt AC 5 ms 1280 KB
48.txt AC 8 ms 1408 KB
49.txt AC 18 ms 1664 KB
50.txt AC 12 ms 1536 KB
51.txt AC 2 ms 1280 KB
52.txt AC 2 ms 1280 KB
53.txt WA 29 ms 2048 KB
54.txt AC 20 ms 1792 KB
55.txt WA 26 ms 1920 KB
56.txt AC 3 ms 1280 KB
57.txt AC 7 ms 1408 KB
58.txt AC 8 ms 1408 KB
59.txt AC 2 ms 1280 KB
60.txt AC 2 ms 1280 KB
61.txt WA 5 ms 1280 KB
62.txt AC 8 ms 1408 KB
63.txt AC 23 ms 1792 KB
64.txt AC 7 ms 1408 KB
65.txt AC 2 ms 1280 KB
66.txt AC 2 ms 1280 KB
67.txt AC 37 ms 2304 KB
68.txt AC 37 ms 2304 KB
69.txt AC 37 ms 2304 KB
70.txt WA 2 ms 1280 KB
71.txt AC 2 ms 1280 KB
72.txt AC 2 ms 1280 KB
73.txt AC 2 ms 1280 KB
74.txt AC 2 ms 1280 KB
75.txt AC 2 ms 1280 KB
76.txt AC 2 ms 1280 KB
77.txt AC 2 ms 1280 KB
78.txt AC 37 ms 2304 KB
79.txt AC 2 ms 1280 KB
80.txt AC 2 ms 1280 KB
81.txt AC 2 ms 1280 KB
82.txt AC 2 ms 1280 KB
83.txt AC 3 ms 1280 KB
84.txt AC 3 ms 1280 KB
85.txt AC 2 ms 1280 KB
86.txt AC 2 ms 1280 KB
87.txt AC 2 ms 1280 KB
88.txt AC 3 ms 1408 KB
89.txt AC 2 ms 1280 KB
90.txt AC 2 ms 1280 KB
91.txt AC 2 ms 1280 KB
92.txt AC 2 ms 1280 KB
93.txt AC 2 ms 1280 KB
94.txt AC 2 ms 1280 KB
95.txt AC 2 ms 1280 KB
96.txt WA 2 ms 1280 KB
97.txt AC 2 ms 1280 KB
98.txt AC 2 ms 1280 KB
99.txt AC 2 ms 1280 KB
s1.txt AC 2 ms 1280 KB
s2.txt AC 2 ms 1280 KB
s3.txt AC 2 ms 1280 KB