제출 #20484

#제출 시각아이디문제언어결과실행 시간메모리
20484볼빨간민돌이 (#35)초음속철도 (OJUZ11_rail)C++11
18 / 100
449 ms1340 KiB
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXM = 20;
const int mod = 1e9+7;
int n, m, s[MAXM+1], e[MAXM+1];

bool use[MAXM+1];

int check(){
	vector<pair<int,int>> v;

    for(int i=1; i<=m; i++)
		if(use[i]) v.push_back(make_pair(s[i], e[i]));
    sort(v.begin(), v.end());
    if(v.empty()) return 0;

    int now=1;
    for(auto &e:v){
		if(e.first > now) break;
		else now=max(now, e.second);
    }
    return now==n;
}

int f(int now){
	if(now==m+1) return check();

	int sum=0;
	use[now]=true;
	sum+=f(now+1);
	use[now]=false;
	sum+=f(now+1);
	return sum;
}

int main(){
	scanf("%d %d", &n, &m);
    for(int i=1; i<=m; i++)
		scanf("%d %d", &s[i], &e[i]);
    printf("%d", f(1));
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'int main()':
rail.cpp:40:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
rail.cpp:42:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &s[i], &e[i]);
                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...