# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20484 | 볼빨간민돌이 (#35) | 초음속철도 (OJUZ11_rail) | C++11 | 449 ms | 1340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |