Submission #31525792
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
std::vector<std::string> split(const std::string& text, const char delim);
using ll = long long int;
using llu = unsigned long long int;
int main(){
string buffer;
getline(cin, buffer);
auto size_list = split(buffer, ' ');
const int H = stoi(size_list[0]);
const int W = stoi(size_list[1]);
vector<vector<int>> table;
table.resize(H+2);
for(auto& line : table){
line.resize(W+2, 0);
}
for(int w = 0; w < W + 2; ++w){
table[0][w] = -1;
table[H+1][w] = -1;
}
for(int h = 0; h < H + 2; ++h){
table[h][0] = -1;
table[h][W+1] = -1;
}
getline(cin, buffer);
auto point_list = split(buffer, ' ');
const int R = stoi(point_list[0]);
const int C = stoi(point_list[1]);
int result = 0;
if(table[R-1][C] == 0){
++result;
}
if(table[R+1][C] == 0){
++result;
}
if(table[R][C-1] == 0){
++result;
}
if(table[R][C+1] == 0){
++result;
}
cout << result << endl;
return 0;
}
std::vector<std::string> split(const std::string& text, const char delim){
std::vector<std::string> item_list;
std::stringstream ss(text);
std::string buffer;
const size_t NUM_ITEM = std::count(text.begin(), text.end(), delim);
item_list.reserve(NUM_ITEM + 1);
while ( std::getline(ss, buffer, delim) ) {
if (!buffer.empty()) {
item_list.emplace_back(buffer);
}
}
return item_list;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Adjacent Squares |
| User | low10603 |
| Language | C++ (GCC 9.2.1) |
| Score | 100 |
| Code Size | 1664 Byte |
| Status | AC |
| Exec Time | 6 ms |
| Memory | 3588 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 100 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_06.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_06.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample_01.txt | AC | 6 ms | 3544 KiB |
| sample_02.txt | AC | 2 ms | 3532 KiB |
| sample_03.txt | AC | 2 ms | 3568 KiB |
| sample_04.txt | AC | 2 ms | 3540 KiB |
| sample_05.txt | AC | 2 ms | 3456 KiB |
| sample_06.txt | AC | 2 ms | 3580 KiB |
| test_01.txt | AC | 3 ms | 3456 KiB |
| test_02.txt | AC | 2 ms | 3528 KiB |
| test_03.txt | AC | 1 ms | 3572 KiB |
| test_04.txt | AC | 2 ms | 3588 KiB |
| test_05.txt | AC | 2 ms | 3528 KiB |
| test_06.txt | AC | 2 ms | 3484 KiB |
| test_07.txt | AC | 2 ms | 3552 KiB |
| test_08.txt | AC | 2 ms | 3484 KiB |
| test_09.txt | AC | 2 ms | 3548 KiB |