Submission #660

# Submission time Handle Problem Language Result Execution time Memory
660 2013-03-01T01:37:10 Z pl0892029 지도 색칠하기 (GA3_map) C++
Compilation error
0 ms 0 KB
#include <algorithm>
using namespace std;

typedef struct edge
{
    int u,v;
}edge;

bool cmp(edge a,edge b){return a.u==b.u ? a.v<b.v : a.u<b.u;}

long long NumberOfMaps(int N,int M,int *A,int *B)
{
    edge arr[400];
    int table[400]=0, n;
    int chk[21]=0, cnt[21]=0, queue[21], h,t;

    int i,j,m;
    long long ret = 1, tmp = 1;
    for(i=0;i<M;i++)
    {
        arr[2*i].u=A[i],arr[2*i].v=B[i];
        arr[2*i+1].u=B[i], arr[2*i+1].v=A[i];
    }
    n=2*M;
    sort(arr,arr+n,cmp);
    for(i=1;i<n;i++) if(arr[i-1].u==arr[i].u && arr[i-1].v==arr[i].v) table[i]=1;
    for(i=1;i<=N;i++)
    {
        if( chk[i]==2 ) continue;
        tmp = 1, h=0, t=0;
        queue[t++]=i, chk[i]=1;
        while(h<t)
        {
            m=queue[h++];
            chk[m]=2; // finish
            tmp *= 4-cnt[m];
            for(j=0;j<n;j++)
            {
                if(table[j]==1) continue;
                if(arr[j].u==m)
                {
                    if(chk[arr[j].v]<2) cnt[arr[j].v]++;
                    if(chk[arr[j].v]==0)
                    {
                        queue[t++]=arr[j].v;
                        chk[arr[j].v]=1;
                    }
                }
            }
        }
        ret *= tmp;
    }
    return ret;
}

Compilation message

map.cpp: In function 'long long int NumberOfMaps(int, int, int*, int*)':
map.cpp:14: error: array must be initialized with a brace-enclosed initializer
map.cpp:15: error: array must be initialized with a brace-enclosed initializer
map.cpp:15: error: array must be initialized with a brace-enclosed initializer