Submission #367868

# Submission time Handle Problem Language Result Execution time Memory
367868 2021-02-18T15:24:08 Z vaaven Dango Maker (JOI18_dango_maker) C++14
13 / 100
35 ms 47596 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <stack>
#include <iomanip>
#include <bitset>
#include <map>
#include <cassert>
#include <array>
#include <queue>
#include <cstring>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
 #define int long  long
    
using namespace std;
    
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
    
const int inf = 1e9 + 228;
const int infll = 1e18;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ld eps = 1e-14;
    
    
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("a.in", "r", stdin);
//    freopen("outputik.txt", "w", stdout);
}

const int maxn = 3e3;

string kek[maxn];
int lol[maxn][maxn][2];
bool used[2000000];

vi g[2000000];
int cnt = 0;


int dfs(int v, int col = 0){
    int cur = col;
    cnt++;
    used[v] = true;
    for(int i:g[v]){
        if(!used[i]){
            cur += dfs(i, col^1);
        }
    }
    return cur;
}

void solve(){
    int n, m;
    cin >> n >> m;
    for(int i=0; i<n; i++){
        cin >> kek[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            lol[i][j][0] = lol[i][j][1] = -1;
        }
    }
    int count = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(j + 2 < m && kek[i][j] == 'R' && kek[i][j+1] == 'G' && kek[i][j+2] == 'W'){
                lol[i][j][1] = count;
                lol[i][j+1][1] = count;
                lol[i][j+2][1] = count++;
            }
            if(i + 2 < n && kek[i][j] == 'R' && kek[i+1][j] == 'G' && kek[i+2][j] == 'W'){
                lol[i][j][0] = count;
                lol[i+1][j][0] = count;
                lol[i+2][j][0] = count++;
            }
            if(lol[i][j][0] >= 0 && lol[i][j][1] >= 0){
//                cout << i << " " << j << endl;
                g[lol[i][j][0]].pb(lol[i][j][1]);
                g[lol[i][j][1]].pb(lol[i][j][0]);
            }
        }
    }
    int ans = 0;
    for(int i=0; i<count; i++){
        if(!used[i]){
            cnt = 0;
            int kek = dfs(i);
//            cout << kek << endl;
            ans += max(kek, cnt-kek);
        }
    }
    cout << ans << endl;
}

signed main(){
     fast_io();
//  ;(time(NULL));
    cout << fixed << setprecision(10);
    int q = 1;
//    cin >> q;
    while(q--)
        solve();
}
# Verdict Execution time Memory Grader output
1 Correct 32 ms 47468 KB Output is correct
2 Correct 32 ms 47468 KB Output is correct
3 Correct 32 ms 47468 KB Output is correct
4 Correct 33 ms 47468 KB Output is correct
5 Correct 33 ms 47468 KB Output is correct
6 Correct 32 ms 47468 KB Output is correct
7 Correct 33 ms 47468 KB Output is correct
8 Correct 32 ms 47468 KB Output is correct
9 Correct 32 ms 47488 KB Output is correct
10 Correct 32 ms 47468 KB Output is correct
11 Correct 32 ms 47468 KB Output is correct
12 Correct 32 ms 47468 KB Output is correct
13 Correct 32 ms 47468 KB Output is correct
14 Correct 33 ms 47596 KB Output is correct
15 Correct 35 ms 47392 KB Output is correct
16 Correct 32 ms 47468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 47468 KB Output is correct
2 Correct 32 ms 47468 KB Output is correct
3 Correct 32 ms 47468 KB Output is correct
4 Correct 33 ms 47468 KB Output is correct
5 Correct 33 ms 47468 KB Output is correct
6 Correct 32 ms 47468 KB Output is correct
7 Correct 33 ms 47468 KB Output is correct
8 Correct 32 ms 47468 KB Output is correct
9 Correct 32 ms 47488 KB Output is correct
10 Correct 32 ms 47468 KB Output is correct
11 Correct 32 ms 47468 KB Output is correct
12 Correct 32 ms 47468 KB Output is correct
13 Correct 32 ms 47468 KB Output is correct
14 Correct 33 ms 47596 KB Output is correct
15 Correct 35 ms 47392 KB Output is correct
16 Correct 32 ms 47468 KB Output is correct
17 Correct 34 ms 47432 KB Output is correct
18 Correct 32 ms 47468 KB Output is correct
19 Correct 33 ms 47468 KB Output is correct
20 Correct 32 ms 47468 KB Output is correct
21 Correct 32 ms 47468 KB Output is correct
22 Correct 33 ms 47468 KB Output is correct
23 Correct 32 ms 47468 KB Output is correct
24 Correct 32 ms 47468 KB Output is correct
25 Correct 32 ms 47468 KB Output is correct
26 Correct 34 ms 47468 KB Output is correct
27 Correct 33 ms 47468 KB Output is correct
28 Correct 32 ms 47468 KB Output is correct
29 Correct 32 ms 47468 KB Output is correct
30 Correct 32 ms 47468 KB Output is correct
31 Correct 32 ms 47468 KB Output is correct
32 Correct 33 ms 47468 KB Output is correct
33 Correct 32 ms 47468 KB Output is correct
34 Incorrect 32 ms 47468 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 47468 KB Output is correct
2 Correct 32 ms 47468 KB Output is correct
3 Correct 32 ms 47468 KB Output is correct
4 Correct 33 ms 47468 KB Output is correct
5 Correct 33 ms 47468 KB Output is correct
6 Correct 32 ms 47468 KB Output is correct
7 Correct 33 ms 47468 KB Output is correct
8 Correct 32 ms 47468 KB Output is correct
9 Correct 32 ms 47488 KB Output is correct
10 Correct 32 ms 47468 KB Output is correct
11 Correct 32 ms 47468 KB Output is correct
12 Correct 32 ms 47468 KB Output is correct
13 Correct 32 ms 47468 KB Output is correct
14 Correct 33 ms 47596 KB Output is correct
15 Correct 35 ms 47392 KB Output is correct
16 Correct 32 ms 47468 KB Output is correct
17 Correct 34 ms 47432 KB Output is correct
18 Correct 32 ms 47468 KB Output is correct
19 Correct 33 ms 47468 KB Output is correct
20 Correct 32 ms 47468 KB Output is correct
21 Correct 32 ms 47468 KB Output is correct
22 Correct 33 ms 47468 KB Output is correct
23 Correct 32 ms 47468 KB Output is correct
24 Correct 32 ms 47468 KB Output is correct
25 Correct 32 ms 47468 KB Output is correct
26 Correct 34 ms 47468 KB Output is correct
27 Correct 33 ms 47468 KB Output is correct
28 Correct 32 ms 47468 KB Output is correct
29 Correct 32 ms 47468 KB Output is correct
30 Correct 32 ms 47468 KB Output is correct
31 Correct 32 ms 47468 KB Output is correct
32 Correct 33 ms 47468 KB Output is correct
33 Correct 32 ms 47468 KB Output is correct
34 Incorrect 32 ms 47468 KB Output isn't correct
35 Halted 0 ms 0 KB -