提出 #69659243
ソースコード 拡げる
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef jlocal
#include<jdebug/debug.hpp>
#else
#define debug(...) 0;
#endif
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#if defined(__LP64__) || defined(_WIN64)
typedef __int128 lll;
#else
typedef long long lll;
#endif
#define pcount(x) __builtin_popcount(x)
#define pcountll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
const ld pi = 3.14159265358979323846L;
const ld sqrt2 = 1.41421356237309504880L;
template<class T>
istream& operator>>(istream& in, vector<T> &a){
for (int i = 0; i < a.size(); i ++)
in >> a[i];
return in;
}
template<class T>
ostream& operator<<(ostream& out, vector<T> &a){
for (int i = 0; i < a.size(); i ++){
if (i > 0) out << ' ';
out << a[i];
}
return out;
}
#if defined(__LP64__) || defined(_WIN64)
istream& operator>>(istream& in, __int128 &x){
string S;
in >> S;
for (char &y : S){
x *= 10;
x += (y - '0');
}
return in;
}
ostream& operator<<(ostream& out, __int128 &x){
string s;
while(x > 0){
s.push_back((x % 10) + '0');
x /= 10;
}
if (s.size() == 0)
s.push_back('0');
reverse(all(s));
return out << s;
}
#endif
mt19937_64 MT64;
void pre_init() {
MT64 = mt19937_64(chrono::system_clock::now().
time_since_epoch().count());
}
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
void solve(int caso){
int n, m;
cin >> n >> m;
vector<string> mat(n);
cin >> mat;
vector<pair<int, int>> revisar;
for (int i = 0; i < n; i ++){
for (int j = 0; j < m; j ++){
if (mat[i][j] == '#'){
revisar.emplace_back(i, j);
}
}
}
while(revisar.size() > 0){
set<pair<int, int>> revisar2;
debug(revisar);
for (auto [x, y] : revisar){
for (int k = 0; k < 4; k ++){
int nx = x + dx[k];
int ny = y + dy[k];
if (nx < 0 or ny < 0 or nx >= n or ny >= m)
continue;
if (mat[nx][ny] != '.')
continue;
int hay = 0;
for (int k2 = 0; k2 < 4; k2 ++){
int nx2 = nx + dx[k2];
int ny2 = ny + dy[k2];
if (nx2 < 0 or ny2 < 0 or nx2 >= n or ny2 >= m)
continue;
if (mat[nx2][ny2] == '#')
hay ++;
}
debug(hay);
if (hay == 1)
revisar2.insert({nx, ny});
}
}
debug(revisar2);
revisar.resize(0);
for (auto [x, y] : revisar2){
mat[x][y] = '#';
revisar.emplace_back(x, y);
}
}
int ans = 0;
for (int i = 0; i < n; i ++){
for (int j = 0; j < m; j ++){
if (mat[i][j] == '#')
ans ++;
}
}
cout << ans << '\n';
}
int main(){
#ifndef jlocal
ios::sync_with_stdio(0); cin.tie(0);
#endif
pre_init();
int t = 1;
for (int i = 1; i <= t; i ++){
solve(i);
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Ulam-Warburton Automaton |
| ユーザ | JOliva |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 425 |
| コード長 | 3085 Byte |
| 結果 | AC |
| 実行時間 | 38 ms |
| メモリ | 9132 KiB |
コンパイルエラー
Main.cpp: In function ‘void solve(int)’:
Main.cpp:8:20: warning: statement has no effect [-Wunused-value]
8 | #define debug(...) 0;
| ^
Main.cpp:100:17: note: in expansion of macro ‘debug’
100 | debug(revisar);
| ^~~~~
Main.cpp:8:20: warning: statement has no effect [-Wunused-value]
8 | #define debug(...) 0;
| ^
Main.cpp:121:33: note: in expansion of macro ‘debug’
121 | debug(hay);
| ^~~~~
Main.cpp:8:20: warning: statement has no effect [-Wunused-value]
8 | #define debug(...) 0;
| ^
Main.cpp:126:17: note: in expansion of macro ‘debug’
126 | debug(revisar2);
| ^~~~~
Main.cpp:84:16: warning: unused parameter ‘caso’ [-Wunused-parameter]
84 | void solve(int caso){
| ~~~~^~~~
Main.cpp: In instantiation of ‘std::istream& operator>>(std::istream&, std::vector<_Tp>&) [with T = std::__cxx11::basic_string<char>; std::istream = std::basic_istream<char>]’:
Main.cpp:88:9: required from here
Main.cpp:36:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
36 | for (int i = 0; i < a.size(); i ++)
| ~~^~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 425 / 425 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3528 KiB |
| 00_sample_01.txt | AC | 1 ms | 3512 KiB |
| 00_sample_02.txt | AC | 1 ms | 3528 KiB |
| 01_test_00.txt | AC | 25 ms | 7656 KiB |
| 01_test_01.txt | AC | 6 ms | 4212 KiB |
| 01_test_02.txt | AC | 7 ms | 4476 KiB |
| 01_test_03.txt | AC | 15 ms | 5760 KiB |
| 01_test_04.txt | AC | 27 ms | 7780 KiB |
| 01_test_05.txt | AC | 15 ms | 5928 KiB |
| 01_test_06.txt | AC | 16 ms | 5888 KiB |
| 01_test_07.txt | AC | 14 ms | 5564 KiB |
| 01_test_08.txt | AC | 38 ms | 8428 KiB |
| 01_test_09.txt | AC | 36 ms | 9132 KiB |
| 01_test_10.txt | AC | 20 ms | 4276 KiB |
| 01_test_11.txt | AC | 25 ms | 4388 KiB |
| 01_test_12.txt | AC | 28 ms | 4600 KiB |
| 01_test_13.txt | AC | 29 ms | 4540 KiB |
| 01_test_14.txt | AC | 30 ms | 4604 KiB |
| 01_test_15.txt | AC | 32 ms | 4768 KiB |
| 01_test_16.txt | AC | 32 ms | 5232 KiB |
| 01_test_17.txt | AC | 34 ms | 5800 KiB |
| 01_test_18.txt | AC | 36 ms | 6224 KiB |
| 01_test_19.txt | AC | 37 ms | 6784 KiB |
| 01_test_20.txt | AC | 11 ms | 3764 KiB |
| 01_test_21.txt | AC | 13 ms | 3836 KiB |
| 01_test_22.txt | AC | 14 ms | 3708 KiB |
| 01_test_23.txt | AC | 21 ms | 3696 KiB |
| 01_test_24.txt | AC | 27 ms | 3936 KiB |
| 01_test_25.txt | AC | 28 ms | 4136 KiB |
| 01_test_26.txt | AC | 31 ms | 4392 KiB |
| 01_test_27.txt | AC | 34 ms | 4776 KiB |
| 01_test_28.txt | AC | 15 ms | 4092 KiB |
| 01_test_29.txt | AC | 19 ms | 6248 KiB |
| 01_test_30.txt | AC | 18 ms | 4772 KiB |
| 01_test_31.txt | AC | 20 ms | 4428 KiB |
| 01_test_32.txt | AC | 25 ms | 4940 KiB |
| 01_test_33.txt | AC | 27 ms | 5036 KiB |
| 01_test_34.txt | AC | 26 ms | 5276 KiB |
| 01_test_35.txt | AC | 29 ms | 5760 KiB |
| 01_test_36.txt | AC | 11 ms | 3716 KiB |