Submission #833

# Submission time Handle Problem Language Result Execution time Memory
833 2013-03-10T09:11:06 Z gs13068 지도 색칠하기 (GA3_map) C++
85 / 120
1500 ms 952 KB
#include<vector>
#include<set>
#include<cstdio>

std::vector<int> graph[20];
std::vector<int> group[20];

struct pair
{
int a;
int b;
int c;
} temp,te;

bool operator <(const pair &a,const pair &b)
{
if(a.a!=b.a)return a.a>b.a;
if(a.b!=b.b)return a.b>b.b;
return a.c<b.c;
}

int A[20];
int B[20];
bool erased[20];

int pos[20];
int color[20];

std::set<pair> s;

inline long long Number(int x,int y)
{
if(y==group[x].size())return 1;
int i;
long long res=0;
bool a,b,c,d;
a=b=c=d=true;
for(i=0;i<graph[group[x][y]].size();i++)
{
if(pos[graph[group[x][y]][i]]<pos[group[x][y]])
{
if(color[graph[group[x][y]][i]]==1)a=false;
else if(color[graph[group[x][y]][i]]==2)b=false;
else if(color[graph[group[x][y]][i]]==3)c=false;
else d=false;
}
}
if(a){color[group[x][y]]=1;res+=Number(x,y+1);}
if(b){color[group[x][y]]=2;res+=Number(x,y+1);}
if(c){color[group[x][y]]=3;res+=Number(x,y+1);}
if(d){color[group[x][y]]=4;res+=Number(x,y+1);}
return res;
}

long long NumberOfMaps(int n, int m, int *a, int *b)
{
long long res=1;
int i,j,cnt;
for(i=0;i<m;i++){graph[a[i]-1].push_back(b[i]-1);graph[b[i]-1].push_back(a[i]-1);}
for(i=0;i<n;i++){A[i]=temp.a=0;B[i]=temp.b=graph[i].size();temp.c=i;s.insert(temp);erased[i]=false;}
for(cnt=0;!s.empty();cnt++)
{
do
{
temp=*s.begin();
s.erase(s.begin());
pos[temp.c]=group[cnt].size();
group[cnt].push_back(temp.c);
erased[temp.c]=true;
for(i=0;i<graph[temp.c].size();i++)
{
if(erased[graph[temp.c][i]])continue;
te.a=A[graph[temp.c][i]];
te.b=B[graph[temp.c][i]];
te.c=graph[temp.c][i];
s.erase(s.find(te));
A[graph[temp.c][i]]++;
B[graph[temp.c][i]]--;
te.a++;
te.b--;
s.insert(te);
}
}while(s.begin()->a);
}
for(i=0;i<cnt;i++)
{
if(group[i].size()==1)res*=4;
else if(group[i].size()==2)res*=12;
else
{
color[group[i][0]]=1;
color[group[i][1]]=2;
res*=Number(i,2)*12;
}
}
return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 952 KB Output is correct
2 Correct 0 ms 952 KB Output is correct
3 Correct 0 ms 952 KB Output is correct
4 Correct 0 ms 952 KB Output is correct
5 Correct 0 ms 952 KB Output is correct
6 Correct 0 ms 952 KB Output is correct
7 Correct 0 ms 952 KB Output is correct
8 Correct 0 ms 952 KB Output is correct
9 Correct 0 ms 952 KB Output is correct
10 Correct 0 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 952 KB Output is correct
2 Correct 0 ms 952 KB Output is correct
3 Correct 0 ms 952 KB Output is correct
4 Correct 0 ms 952 KB Output is correct
5 Correct 0 ms 952 KB Output is correct
6 Correct 0 ms 952 KB Output is correct
7 Correct 0 ms 952 KB Output is correct
8 Correct 0 ms 952 KB Output is correct
9 Correct 0 ms 952 KB Output is correct
10 Correct 0 ms 952 KB Output is correct
11 Correct 0 ms 952 KB Output is correct
12 Correct 0 ms 952 KB Output is correct
13 Correct 0 ms 952 KB Output is correct
14 Correct 0 ms 952 KB Output is correct
15 Correct 0 ms 952 KB Output is correct
16 Correct 0 ms 952 KB Output is correct
17 Correct 0 ms 952 KB Output is correct
18 Correct 0 ms 952 KB Output is correct
19 Correct 0 ms 952 KB Output is correct
20 Correct 0 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 952 KB Output is correct
2 Correct 0 ms 952 KB Output is correct
3 Correct 0 ms 952 KB Output is correct
4 Correct 0 ms 952 KB Output is correct
5 Correct 0 ms 952 KB Output is correct
6 Correct 0 ms 952 KB Output is correct
7 Correct 0 ms 952 KB Output is correct
8 Correct 0 ms 952 KB Output is correct
9 Correct 0 ms 952 KB Output is correct
10 Correct 0 ms 952 KB Output is correct
11 Correct 0 ms 952 KB Output is correct
12 Correct 0 ms 952 KB Output is correct
13 Correct 0 ms 952 KB Output is correct
14 Correct 0 ms 952 KB Output is correct
15 Correct 0 ms 952 KB Output is correct
16 Correct 0 ms 952 KB Output is correct
17 Correct 0 ms 952 KB Output is correct
18 Correct 0 ms 952 KB Output is correct
19 Correct 0 ms 952 KB Output is correct
20 Correct 0 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 952 KB Output is correct
2 Correct 0 ms 952 KB Output is correct
3 Correct 0 ms 952 KB Output is correct
4 Correct 0 ms 952 KB Output is correct
5 Correct 0 ms 952 KB Output is correct
6 Correct 2 ms 952 KB Output is correct
7 Correct 13 ms 952 KB Output is correct
8 Correct 0 ms 952 KB Output is correct
9 Correct 0 ms 952 KB Output is correct
10 Correct 0 ms 952 KB Output is correct
11 Correct 0 ms 952 KB Output is correct
12 Correct 0 ms 952 KB Output is correct
13 Correct 0 ms 952 KB Output is correct
14 Correct 0 ms 952 KB Output is correct
15 Correct 0 ms 952 KB Output is correct
16 Correct 3 ms 952 KB Output is correct
17 Correct 3 ms 952 KB Output is correct
18 Correct 0 ms 952 KB Output is correct
19 Correct 0 ms 952 KB Output is correct
20 Correct 0 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 952 KB Output is correct
2 Correct 0 ms 952 KB Output is correct
3 Correct 0 ms 952 KB Output is correct
4 Correct 0 ms 952 KB Output is correct
5 Correct 0 ms 952 KB Output is correct
6 Correct 11 ms 952 KB Output is correct
7 Correct 14 ms 952 KB Output is correct
8 Correct 3 ms 952 KB Output is correct
9 Correct 0 ms 952 KB Output is correct
10 Correct 9 ms 952 KB Output is correct
11 Correct 0 ms 952 KB Output is correct
12 Correct 0 ms 952 KB Output is correct
13 Correct 0 ms 952 KB Output is correct
14 Correct 0 ms 952 KB Output is correct
15 Correct 0 ms 952 KB Output is correct
16 Correct 10 ms 952 KB Output is correct
17 Correct 17 ms 952 KB Output is correct
18 Correct 0 ms 952 KB Output is correct
19 Correct 0 ms 952 KB Output is correct
20 Correct 0 ms 952 KB Output is correct
21 Correct 28 ms 952 KB Output is correct
22 Correct 33 ms 952 KB Output is correct
23 Correct 0 ms 952 KB Output is correct
24 Correct 0 ms 952 KB Output is correct
25 Correct 0 ms 952 KB Output is correct
26 Execution timed out 1500 ms 0 KB Program timed out
27 Halted 0 ms 0 KB -
28 Halted 0 ms 0 KB -
29 Halted 0 ms 0 KB -
30 Halted 0 ms 0 KB -