Submission #17297

# Submission time Handle Problem Language Result Execution time Memory
17297 2015-11-19T07:34:26 Z gs14004 지도 색칠하기 (GA3_map) C++14
Compilation error
0 ms 0 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

struct disj{
	int pa[42];
	void init(int n){
		for(int i=1; i<=n; i++) pa[i] = i;
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q){
		p = find(p);
		q = find(q);
		if(p == q) return 0;
		pa[q] = p;
		return 1;
	}
}disj;

int n, m;
int s[200], e[200];

int main(){
	lint sum = 0;
	scanf("%d %d",&n,&m);
	for(int i=0; i<m; i++){
		scanf("%d %d",&s[i],&e[i]);
	}
	for(int i=0; i<(1<<(n-1)); i++){
		disj.init(2*n);
		bool bad = 0;
		for(int j=0; j<m; j++){
			if(((i >> (s[j] - 1)) & 1) == ((i >> (e[j] - 1)) & 1)){
				disj.uni(s[j], e[j] + n);
				disj.uni(e[j], s[j] + n);
				if(disj.find(s[j]) == disj.find(s[j] + n)){
					bad = 1;
					break;
				}
			}
		}
		if(bad) continue;
		int cnt = 0;
		for(int i=1; i<=2*n; i++){
			if(disj.uni(i, 1)){
				cnt++;
			}
		}
		cnt = (cnt + 1) / 2;
		sum += (2 << cnt);
	}
	printf("%lld",sum);
}

Compilation message

map.cpp: In function ‘int main()’:
map.cpp:46:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
                      ^
map.cpp:48:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&s[i],&e[i]);
                             ^
/tmp/ccdxiE0p.o: In function `main':
map.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc6Oe6rp.o:grader.cpp:(.text.startup+0x0): first defined here
/tmp/cc6Oe6rp.o: In function `main':
grader.cpp:(.text.startup+0xeb): undefined reference to `NumberOfMaps(int, int, int*, int*)'
collect2: error: ld returned 1 exit status