답안 #402934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402934 2021-05-12T14:37:53 Z teehandsome 무지개나라 (APIO17_rainbow) C++11
0 / 100
16 ms 716 KB
#include "rainbow.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool flag[51][51];
bool flag2[51][51];
int dm[4]={-1,0,1,0};
int dn[4]={0,1,0,-1};
char dir[4]={'N','E','S','W'};

void init(int R, int C, int sr, int sc, int M, char *S) {
    flag[sr][sc]=true;
    for(int i=0;i<M;i++) {
        for(int j=0;j<4;j++) {
            if(S[i]==dir[j]) {
                sr+=dm[j]; sc+=dn[j]; break;
            }
        }
        flag[sr][sc]=true;
    }
}

void bfs(int sm,int sn,int &ar,int &ac,int &br,int &bc) {
    memset(flag2,false,sizeof(flag2));
    queue<pii> q;
    q.push({sm,sn});
    while(!q.empty()) {
        pii cur=q.front(); q.pop();
        int M=cur.first,N=cur.second;
        flag2[M][N]=true;
        for(int i=0;i<4;i++) {
            int mm=M+dm[i],nn=N+dn[i];
            if(mm>=ar and mm<=br and nn>=ac and nn<=bc) {
                if(!flag2[mm][nn] and !flag[mm][nn]) {
                    flag2[mm][nn]=true;
                    q.push({mm,nn});
                }
            }
        }
    }
}

int colour(int ar, int ac, int br, int bc) {
    int ans=0;
    for(int i=ar;i<=br;i++) {
        for(int j=ac;j<=bc;j++) {
            if(flag[i][j] or flag2[i][j]) continue;
            bfs(i,j,ar,ac,br,bc); ans++;
        }
    }
    return ans;
}


# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 2 ms 716 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -