답안 #52359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52359 2018-06-25T15:16:31 Z ainch(#1359) 비밀 (JOI14_secret) C++11
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int M = 12;
const int N = 1002;

using lint = long long;

int a[M], b[M], c[M], d[M];

int m, n;

lint cost (int o) {
	lint r = 0;
	for (int i = 0; i < m; i++) {
		if (o & (1 << i)) {
			r = r + (lint)d[i];
		}
	}
	return r;
}

bool get (int o) {
	vector < bool > v(n+1,false);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		int p = i;

		for (int j = 0; j < m; j++) {
			if (o & (1 << j)) {
				if (a[j] <= p && p <= b[j]) {
					p = c[j];
				}
			}
		}
	
		if (!v[p]) {
			v[p] = true;
			++cnt;
		}
	}
	if (cnt == 1)return true;
	else return false;
}

int main () {
	freopen ("in.txt", "r", stdin);
	scanf ("%d%d", &m, &n);
	for (int i = 0; i < m; i++) {
		scanf ("%d%d%d%d", a + i, b + i, c + i, d + i);
	}
	lint t = 1e12;
	for (int i = 0; i < (1 << m); i++) {
		if (get (i)) {
			t = min (t, cost (i));
		}
	}
	if (t == 1e12) {
		puts ("-1");
	}
	else {
		printf ("%lld\n", t);
	}

	return 0;
}

Compilation message

secret.cpp: In function 'int main()':
secret.cpp:49:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen ("in.txt", "r", stdin);
  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
secret.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%d", &m, &n);
  ~~~~~~^~~~~~~~~~~~~~~~
secret.cpp:52:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d%d%d%d", a + i, b + i, c + i, d + i);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccAkauKW.o: In function `main':
secret.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccBAXfGY.o:grader-full.cpp:(.text.startup+0x0): first defined here
/tmp/ccBAXfGY.o: In function `main':
grader-full.cpp:(.text.startup+0x27b): undefined reference to `Init(int, int*)'
grader-full.cpp:(.text.startup+0x2d3): undefined reference to `Query(int, int)'
collect2: error: ld returned 1 exit status