# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
466054 |
2021-08-17T15:57:37 Z |
SamAnd |
Game (eJOI20_game) |
C++17 |
|
1 ms |
204 KB |
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 22;
int n, m;
char t[N][N], s[N][N];
bool c[N][N];
int q;
void dfs(int x, int y)
{
if (!(1 <= x && x <= n && 1 <= y && y <= m))
return;
if (c[x][y])
return;
++q;
c[x][y] = true;
if (t[x][y] == '0')
dfs(x + 1, y);
if (t[x - 1][y] == '0')
dfs(x - 1, y);
if (s[x][y] == '0')
dfs(x, y + 1);
if (s[x][y - 1] == '0')
dfs(x, y - 1);
}
void solv()
{
cin >> n >> m;
for (int i = 0; i <= n; ++i)
{
cin >> (t[i] + 1);
}
for (int i = 1; i <= n; ++i)
{
cin >> s[i];
}
vector<int> v;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (!c[i][j])
{
q = 0;
dfs(i, j);
if (t[i][j] == '1' && t[i - 1][j] == '1' && s[i][j] == '1' && s[i][j - 1] == '1')
continue;
v.push_back(q);
}
}
}
cout << -v[0] << "\n";
}
int main()
{
#ifdef SOMETHING
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif // SOMETHING
ios_base::sync_with_stdio(false), cin.tie(0);
int tt = 1;
//cin >> tt;
while (tt--)
{
solv();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |