Submission #49453736
Source Code Expand
/**
* @the_hyp0cr1t3
* 20.01.2024 17:38
**/
#include <bits/stdc++.h>
constexpr int inf = 1e9;
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n, m, k;
std::cin >> n >> m >> k;
std::vector<std::string> a(n);
for (auto &x : a)
std::cin >> x;
int ans = inf;
for (int i = 0; i < n; i++) {
int len = 0, sub = 0;
for (int j = 0; j < m; j++) {
if (a[i][j] == 'x') {
len = sub = 0;
} else {
if (len == k)
sub -= a[i][j - len] == 'o';
len = std::min(len + 1, k);
sub += a[i][j] == 'o';
if (len == k)
ans = std::min(ans, len - sub);
}
}
}
for (int j = 0; j < m; j++) {
int len = 0, sub = 0;
for (int i = 0; i < n; i++) {
if (a[i][j] == 'x') {
len = sub = 0;
} else {
if (len == k)
sub -= a[i - len][j] == 'o';
len = std::min(len + 1, k);
sub += a[i][j] == 'o';
if (len == k)
ans = std::min(ans, len - sub);
}
}
}
std::cout << (ans == inf ? -1 : ans) << '\n';
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Cheating Gomoku Narabe |
| User | the_hyp0cr1t3 |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 1341 Byte |
| Status | AC |
| Exec Time | 11 ms |
| Memory | 9388 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt, example3.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, 059.txt, 060.txt, 061.txt, 062.txt, example0.txt, example1.txt, example2.txt, example3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 1 ms | 3468 KiB |
| 001.txt | AC | 1 ms | 3456 KiB |
| 002.txt | AC | 1 ms | 3452 KiB |
| 003.txt | AC | 2 ms | 3584 KiB |
| 004.txt | AC | 2 ms | 3512 KiB |
| 005.txt | AC | 2 ms | 3720 KiB |
| 006.txt | AC | 2 ms | 3580 KiB |
| 007.txt | AC | 10 ms | 9336 KiB |
| 008.txt | AC | 11 ms | 9388 KiB |
| 009.txt | AC | 10 ms | 9244 KiB |
| 010.txt | AC | 10 ms | 9312 KiB |
| 011.txt | AC | 2 ms | 3692 KiB |
| 012.txt | AC | 2 ms | 3768 KiB |
| 013.txt | AC | 2 ms | 3704 KiB |
| 014.txt | AC | 3 ms | 4104 KiB |
| 015.txt | AC | 2 ms | 3732 KiB |
| 016.txt | AC | 3 ms | 3672 KiB |
| 017.txt | AC | 2 ms | 3572 KiB |
| 018.txt | AC | 3 ms | 3588 KiB |
| 019.txt | AC | 2 ms | 3600 KiB |
| 020.txt | AC | 2 ms | 3584 KiB |
| 021.txt | AC | 2 ms | 3692 KiB |
| 022.txt | AC | 2 ms | 3644 KiB |
| 023.txt | AC | 2 ms | 3676 KiB |
| 024.txt | AC | 2 ms | 3740 KiB |
| 025.txt | AC | 2 ms | 3656 KiB |
| 026.txt | AC | 2 ms | 3560 KiB |
| 027.txt | AC | 2 ms | 3836 KiB |
| 028.txt | AC | 2 ms | 3680 KiB |
| 029.txt | AC | 1 ms | 3684 KiB |
| 030.txt | AC | 2 ms | 3596 KiB |
| 031.txt | AC | 3 ms | 3688 KiB |
| 032.txt | AC | 2 ms | 3676 KiB |
| 033.txt | AC | 3 ms | 3724 KiB |
| 034.txt | AC | 2 ms | 3768 KiB |
| 035.txt | AC | 3 ms | 3772 KiB |
| 036.txt | AC | 2 ms | 3560 KiB |
| 037.txt | AC | 3 ms | 3500 KiB |
| 038.txt | AC | 2 ms | 3712 KiB |
| 039.txt | AC | 2 ms | 3608 KiB |
| 040.txt | AC | 2 ms | 3772 KiB |
| 041.txt | AC | 2 ms | 3824 KiB |
| 042.txt | AC | 2 ms | 3696 KiB |
| 043.txt | AC | 2 ms | 3708 KiB |
| 044.txt | AC | 1 ms | 3736 KiB |
| 045.txt | AC | 2 ms | 3724 KiB |
| 046.txt | AC | 1 ms | 3704 KiB |
| 047.txt | AC | 2 ms | 3696 KiB |
| 048.txt | AC | 3 ms | 3544 KiB |
| 049.txt | AC | 2 ms | 3692 KiB |
| 050.txt | AC | 3 ms | 3848 KiB |
| 051.txt | AC | 2 ms | 3740 KiB |
| 052.txt | AC | 3 ms | 3768 KiB |
| 053.txt | AC | 1 ms | 3692 KiB |
| 054.txt | AC | 2 ms | 3620 KiB |
| 055.txt | AC | 2 ms | 3656 KiB |
| 056.txt | AC | 2 ms | 3668 KiB |
| 057.txt | AC | 2 ms | 3612 KiB |
| 058.txt | AC | 2 ms | 3740 KiB |
| 059.txt | AC | 2 ms | 3440 KiB |
| 060.txt | AC | 2 ms | 3676 KiB |
| 061.txt | AC | 2 ms | 3632 KiB |
| 062.txt | AC | 2 ms | 3700 KiB |
| example0.txt | AC | 1 ms | 3472 KiB |
| example1.txt | AC | 1 ms | 3388 KiB |
| example2.txt | AC | 1 ms | 3456 KiB |
| example3.txt | AC | 1 ms | 3476 KiB |