QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623253#5731. CheckerboardoschlimgenAC ✓0ms3848kbC++202.0kb2024-10-09 10:53:432024-10-09 10:53:44

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 10:53:44]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3848kb
  • [2024-10-09 10:53:43]
  • 提交

answer

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <fstream>



class inputParams {
private:
  std::vector<std::string> split (const std::string &s, char delim) {
    std::vector<std::string> result;
    std::stringstream ss (s);
    std::string item;

    while (getline (ss, item, delim)) {
        result.push_back (item);
    }

    return result;
  }

public:
  int rows;
  int cols;
  int wideRows;
  int wideCols;
  std::vector<int> rowSizes;
  std::vector<int> colSizes;

  inputParams(std::istream& input) {
    read(input);
  }

  void read(std::istream& input) {
    std::string line;

    std::getline(input, line);
    std::vector<std::string> lsplit = split(line, ' ');

    rows = std::stoi(lsplit.at(0));
    cols = std::stoi(lsplit.at(1));
    wideRows = std::stoi(lsplit.at(2));
    wideCols = std::stoi(lsplit.at(3));

    for(int i = 0; i < wideRows; ++i) {
      std::getline(input, line);
      rowSizes.push_back(std::stoi(line));
    }

    for(int i = 0; i < wideCols; ++i) {
      std::getline(input, line);
      colSizes.push_back(std::stoi(line));
    }
  }
};

std::string printChecker(const std::vector<int>& rows, const std::vector<int>& cols) {
  bool rowStartColor = true;
  bool checkerColor = true;
  std::string output;

  for(int ri = 0; ri < rows.size(); ++ri) {
    for(int rj = 0; rj < rows.at(ri); ++rj) {
      std::string line;
      checkerColor = rowStartColor;

      for(int ci = 0; ci < cols.size(); ++ci) {
        for(int cj = 0; cj < cols.at(ci); ++cj) {
          if(checkerColor) {
            line += "B";
          } else {
            line += "W";
          }
        }

        checkerColor = !checkerColor;
      }

      output += line + "\n";
    }

    rowStartColor = !rowStartColor;
  }

  return output;
}


int main() {
  inputParams input(std::cin);

  std::string output;
  output = printChecker(input.rowSizes, input.colSizes);

  std::cout << output;

  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3800kb

input:

6 5 3 2
1
2
3
3
2

output:

BBBWW
WWWBB
WWWBB
BBBWW
BBBWW
BBBWW

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

4 4 2 2
1
3
3
1

output:

BBBW
WWWB
WWWB
WWWB

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

20 20 4 14
5
2
9
4
1
2
1
1
1
1
1
1
1
1
1
1
4
3

output:

BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
WBBWBWBWBWBWBWWWWBBB
WBBWBWBWBWBWBWWWWBBB
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWB...

result:

ok 20 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

50 2 43 2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
3
1
2
1
1
1
1
3
1
1
1
1
1
1
1

output:

BW
WB
BW
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
BW
WB
BW
WB
BW
WB
BW
BW
BW
WB
BW
BW
WB
BW
WB
BW
WB
WB
WB
BW
WB
BW
WB
BW

result:

ok 50 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

1 50 1 5
1
1
10
11
22
6

output:

BWWWWWWWWWWBBBBBBBBBBBWWWWWWWWWWWWWWWWWWWWWWBBBBBB

result:

ok single line: 'BWWWWWWWWWWBBBBBBBBBBBWWWWWWWWWWWWWWWWWWWWWWBBBBBB'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

50 1 17 1
4
1
1
1
6
2
3
1
3
5
1
4
5
1
6
2
4
1

output:

B
B
B
B
W
B
W
B
B
B
B
B
B
W
W
B
B
B
W
B
B
B
W
W
W
W
W
B
W
W
W
W
B
B
B
B
B
W
B
B
B
B
B
B
W
W
B
B
B
B

result:

ok 50 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

2 50 2 3
1
1
14
18
18

output:

BBBBBBBBBBBBBBWWWWWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBBB
WWWWWWWWWWWWWWBBBBBBBBBBBBBBBBBBWWWWWWWWWWWWWWWWWW

result:

ok 2 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

50 50 29 44
2
1
1
1
2
1
3
1
1
2
3
3
1
1
2
1
1
3
2
3
3
1
1
2
1
3
1
1
2
1
1
1
2
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1

output:

BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWBWBWBW
BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWBWBWBW
WBWBBWBWWBWBWWBWBWBWBWBWWBWBBWBWBWBWBWBWWBWBWBWBWB
BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWBWBWBW
WBWBBWBWWBWBWWBWBWBWBWBWWBWBBWBWBWBWBWBWWBWBWBWBWB
BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWB...

result:

ok 50 lines