Submission #503594

# Submission time Handle Problem Language Result Execution time Memory
503594 2022-01-08T11:59:42 Z FronPaw Dango Maker (JOI18_dango_maker) C++14
13 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#define mod 1000000007
#define int long long
// https://www.youtube.com/watch?v=t5GDacP_2pQ
using namespace std;
ifstream in ("film.in");
ofstream out ("film.out");
int pow (int a, int b)
{
    int rez = 1;
    while (b)
    {
        if (b&1)
            rez = (rez * a) % mod;
        a = (a * a) % mod;
        b>>=1;
    }
    return rez;
}
int n, m;
int v[3001][3001];
int viz[3001][3001];
bool ok_lin (pair<int, int> poz1, pair<int, int> poz2, pair<int, int> poz3)
{
    int cate = 0;
    if (viz[poz1.first][poz1.second] == 1 || viz[poz2.first][poz2.second] == 1 || viz[poz3.first][poz3.second] == 1)
        return false;
    if (v[poz1.first][poz1.second] != 'R' || v[poz2.first][poz2.second] != 'G' || v[poz3.first][poz3.second] != 'W')
        return 0;
    if (!(poz1.first + 2 > n))
    {
        if (v[poz1.first + 1][poz1.second] == 'G' && v[poz1.first + 2][poz1.second] == 'W')
            cate++;
    }
    if (!(poz2.first - 1 < 0 || poz2.first + 1 > n))
    {
        if (v[poz2.first - 1][poz2.second] == 'R' && v[poz2.first + 1][poz2.second] == 'W')
            cate++;
    }
    if (!(poz2.first - 2 < 0))
    {
        if (v[poz3.first - 2][poz3.second] == 'R' && v[poz3.first - 1][poz3.second] == 'G')
            cate++;
    }
    if (cate == 2 ||  cate == 3)
        return 0;
    return 1;
}
bool ok_col (pair<int, int> poz1, pair<int, int> poz2, pair<int, int> poz3)
{
    if (viz[poz1.first][poz1.second] == 1 || viz[poz2.first][poz2.second] == 1 || viz[poz3.first][poz3.second] == 1)
        return false;
    if (v[poz1.first][poz1.second] == 'R' && v[poz2.first][poz2.second] == 'G' && v[poz3.first][poz3.second] == 'W')
        return true;
    return false;
}
void solve ()
{
    cin >> n >> m;
    for (int i = 1;i<=n;++i)
        for (int j = 1;j<=m;++j)
        {
            char a;
            cin >> a;
            v[i][j] = a;
        }
    int ans = 0;
    for (int i = 1;i <= n;++i)
        for (int j = 1;j<=m - 2;++j)
        {
            pair <int, int> poz1 = {i,j};
            pair <int, int> poz2 = {i,j+1};
            pair <int, int> poz3 = {i,j+2};
            if (ok_lin (poz1, poz2, poz3))
            {
                ans++;
                viz[poz1.first][poz1.second] = 1;
                viz[poz2.first][poz2.second] = 1;
                viz[poz3.first][poz3.second] = 1;
            }
        }
    for (int j = 1;j<=m;++j)
        for (int i = 1;i<=n-2;++i)
        {
            pair <int, int> poz1 = {i, j};
            pair <int, int> poz2 = {i+1, j};
            pair <int, int> poz3 = {i+2, j};
            if (ok_col (poz1, poz2, poz3))
            {
                ans++;
                viz[poz1.first][poz1.second] = 1;
                viz[poz2.first][poz2.second] = 1;
                viz[poz3.first][poz3.second] = 1;
            }
        }
    cout << ans << '\n';
}
main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
}

Compilation message

dango_maker.cpp:98:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   98 | main ()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 316 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Incorrect 0 ms 332 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 316 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Incorrect 0 ms 332 KB Output isn't correct
28 Halted 0 ms 0 KB -