답안 #20433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20433 2017-02-11T13:06:25 Z I_forgot_password(#50, mAng0) 초음속철도 (OJUZ11_rail) C++
45 / 100
3000 ms 28676 KB
#include<bits/stdc++.h>
#define je 1000000007
using namespace std;
pair<int,int> train[200001];
vector<int> cnt;
map<int,int> dict;
long long sum[524288];
long long dp[10001];
int can[10001];
int gae=0;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&(train[i].first),&(train[i].second));
        cnt.push_back(train[i].first);
        cnt.push_back(train[i].second);
    }
    cnt.push_back(-1);
    sort(cnt.begin(),cnt.end());
    int prv = -1;
    if(cnt[1] != 1 || cnt[(int)cnt.size() - 1] != n){
        printf("0");
        return 0;
    }
    for(int i=1;i<cnt.size();i++){
        if(cnt[i-1] != cnt[i]){
            dict[cnt[i]] = gae++;
        }
    }
    sort(train,train+m);
    can[0] = 1; dp[0] = 1;
    for(int j=0;j<m;j++){
        int from = dict[train[j].first];
        int to = dict[train[j].second];
        for(int i=from;i<to;i++){
            if(can[i]){
                can[to] = 1;
                break;
            }
        }
        long long sum = 0;
        for(int i=from;i<to;i++){
            sum = (sum + dp[i]) % je;
        }
        for(int i=to;i<gae;i++){
            dp[i] = (dp[i] * 2) % je;
        }
        dp[to] = (dp[to] + sum) % je;
        /*for(int i=0;i<gae;i++){
            printf("(%d,%lld)\n",can[i],dp[i]);
        }*/
    }
    if(!can[gae-1]){
        printf("0");
    }else{
        printf("%lld",dp[gae-1]);
    }

}

Compilation message

rail.cpp: In function 'int main()':
rail.cpp:26:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<cnt.size();i++){
                  ^
rail.cpp:21:9: warning: unused variable 'prv' [-Wunused-variable]
     int prv = -1;
         ^
rail.cpp:13: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:15:59: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&(train[i].first),&(train[i].second));
                                                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7804 KB Output is correct
2 Correct 0 ms 7804 KB Output is correct
3 Correct 0 ms 7804 KB Output is correct
4 Correct 0 ms 7804 KB Output is correct
5 Correct 0 ms 7804 KB Output is correct
6 Correct 0 ms 7804 KB Output is correct
7 Correct 0 ms 7804 KB Output is correct
8 Correct 0 ms 7804 KB Output is correct
9 Correct 0 ms 7804 KB Output is correct
10 Correct 0 ms 7804 KB Output is correct
11 Correct 0 ms 7804 KB Output is correct
12 Correct 0 ms 7804 KB Output is correct
13 Correct 0 ms 7804 KB Output is correct
14 Correct 0 ms 7804 KB Output is correct
15 Correct 0 ms 7804 KB Output is correct
16 Correct 0 ms 7804 KB Output is correct
17 Correct 0 ms 7804 KB Output is correct
18 Correct 0 ms 7804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7804 KB Output is correct
2 Correct 0 ms 7804 KB Output is correct
3 Correct 0 ms 7804 KB Output is correct
4 Correct 0 ms 7804 KB Output is correct
5 Correct 0 ms 7804 KB Output is correct
6 Correct 0 ms 7804 KB Output is correct
7 Correct 0 ms 7804 KB Output is correct
8 Correct 0 ms 7804 KB Output is correct
9 Correct 0 ms 7804 KB Output is correct
10 Correct 0 ms 7804 KB Output is correct
11 Correct 0 ms 7804 KB Output is correct
12 Correct 0 ms 7804 KB Output is correct
13 Correct 0 ms 7804 KB Output is correct
14 Correct 0 ms 7804 KB Output is correct
15 Correct 0 ms 7804 KB Output is correct
16 Correct 0 ms 7804 KB Output is correct
17 Correct 0 ms 7804 KB Output is correct
18 Correct 0 ms 7804 KB Output is correct
19 Correct 0 ms 7804 KB Output is correct
20 Correct 0 ms 7804 KB Output is correct
21 Correct 0 ms 7804 KB Output is correct
22 Correct 0 ms 7804 KB Output is correct
23 Correct 0 ms 7804 KB Output is correct
24 Correct 0 ms 7804 KB Output is correct
25 Correct 0 ms 7804 KB Output is correct
26 Correct 0 ms 7804 KB Output is correct
27 Correct 0 ms 7804 KB Output is correct
28 Correct 0 ms 7804 KB Output is correct
29 Correct 0 ms 7804 KB Output is correct
30 Correct 0 ms 7804 KB Output is correct
31 Correct 0 ms 7804 KB Output is correct
32 Correct 0 ms 7804 KB Output is correct
33 Correct 0 ms 7804 KB Output is correct
34 Correct 0 ms 7804 KB Output is correct
35 Correct 0 ms 7804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7804 KB Output is correct
2 Correct 0 ms 7804 KB Output is correct
3 Correct 0 ms 7804 KB Output is correct
4 Correct 19 ms 7944 KB Output is correct
5 Execution timed out 3000 ms 12440 KB Execution timed out
6 Execution timed out 3000 ms 27092 KB Execution timed out
7 Execution timed out 3000 ms 26828 KB Execution timed out
8 Correct 0 ms 7804 KB Output is correct
9 Execution timed out 3000 ms 25772 KB Execution timed out
10 Execution timed out 3000 ms 26564 KB Execution timed out
11 Execution timed out 3000 ms 10492 KB Execution timed out
12 Execution timed out 3000 ms 27092 KB Execution timed out
13 Execution timed out 3000 ms 26696 KB Execution timed out
14 Correct 56 ms 10960 KB Output is correct
15 Execution timed out 3000 ms 19304 KB Execution timed out
16 Correct 59 ms 10960 KB Output is correct
17 Execution timed out 3000 ms 27092 KB Execution timed out
18 Execution timed out 3000 ms 27092 KB Execution timed out
19 Execution timed out 3000 ms 24584 KB Execution timed out
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7804 KB Output is correct
2 Correct 0 ms 7804 KB Output is correct
3 Correct 0 ms 7804 KB Output is correct
4 Correct 0 ms 7804 KB Output is correct
5 Correct 0 ms 7804 KB Output is correct
6 Correct 0 ms 7804 KB Output is correct
7 Correct 0 ms 7804 KB Output is correct
8 Correct 0 ms 7804 KB Output is correct
9 Correct 0 ms 7804 KB Output is correct
10 Correct 0 ms 7804 KB Output is correct
11 Correct 0 ms 7804 KB Output is correct
12 Correct 0 ms 7804 KB Output is correct
13 Correct 0 ms 7804 KB Output is correct
14 Correct 0 ms 7804 KB Output is correct
15 Correct 0 ms 7804 KB Output is correct
16 Correct 0 ms 7804 KB Output is correct
17 Correct 0 ms 7804 KB Output is correct
18 Correct 0 ms 7804 KB Output is correct
19 Correct 0 ms 7804 KB Output is correct
20 Correct 0 ms 7804 KB Output is correct
21 Correct 0 ms 7804 KB Output is correct
22 Correct 0 ms 7804 KB Output is correct
23 Correct 0 ms 7804 KB Output is correct
24 Correct 0 ms 7804 KB Output is correct
25 Correct 0 ms 7804 KB Output is correct
26 Correct 0 ms 7804 KB Output is correct
27 Correct 0 ms 7804 KB Output is correct
28 Correct 0 ms 7804 KB Output is correct
29 Correct 0 ms 7804 KB Output is correct
30 Correct 0 ms 7804 KB Output is correct
31 Correct 0 ms 7804 KB Output is correct
32 Correct 0 ms 7804 KB Output is correct
33 Correct 0 ms 7804 KB Output is correct
34 Correct 0 ms 7804 KB Output is correct
35 Correct 0 ms 7804 KB Output is correct
36 Correct 136 ms 8340 KB Output is correct
37 Correct 89 ms 8208 KB Output is correct
38 Correct 29 ms 8076 KB Output is correct
39 Correct 0 ms 7944 KB Output is correct
40 Correct 29 ms 8076 KB Output is correct
41 Correct 3 ms 7944 KB Output is correct
42 Correct 139 ms 8340 KB Output is correct
43 Correct 0 ms 7804 KB Output is correct
44 Correct 113 ms 8208 KB Output is correct
45 Correct 0 ms 7944 KB Output is correct
46 Correct 83 ms 8076 KB Output is correct
47 Correct 63 ms 8076 KB Output is correct
48 Correct 66 ms 8076 KB Output is correct
49 Correct 3 ms 7944 KB Output is correct
50 Correct 3 ms 7944 KB Output is correct
51 Correct 3 ms 7944 KB Output is correct
52 Correct 6 ms 7936 KB Output is correct
53 Correct 3 ms 7944 KB Output is correct
54 Correct 26 ms 7944 KB Output is correct
55 Correct 0 ms 7944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7804 KB Output is correct
2 Correct 0 ms 7804 KB Output is correct
3 Correct 0 ms 7804 KB Output is correct
4 Correct 0 ms 7804 KB Output is correct
5 Correct 0 ms 7804 KB Output is correct
6 Correct 0 ms 7804 KB Output is correct
7 Correct 0 ms 7804 KB Output is correct
8 Correct 0 ms 7804 KB Output is correct
9 Correct 0 ms 7804 KB Output is correct
10 Correct 0 ms 7804 KB Output is correct
11 Correct 0 ms 7804 KB Output is correct
12 Correct 0 ms 7804 KB Output is correct
13 Correct 0 ms 7804 KB Output is correct
14 Correct 0 ms 7804 KB Output is correct
15 Correct 0 ms 7804 KB Output is correct
16 Correct 0 ms 7804 KB Output is correct
17 Correct 0 ms 7804 KB Output is correct
18 Correct 0 ms 7804 KB Output is correct
19 Correct 0 ms 7804 KB Output is correct
20 Correct 0 ms 7804 KB Output is correct
21 Correct 0 ms 7804 KB Output is correct
22 Correct 0 ms 7804 KB Output is correct
23 Correct 0 ms 7804 KB Output is correct
24 Correct 0 ms 7804 KB Output is correct
25 Correct 0 ms 7804 KB Output is correct
26 Correct 0 ms 7804 KB Output is correct
27 Correct 0 ms 7804 KB Output is correct
28 Correct 0 ms 7804 KB Output is correct
29 Correct 0 ms 7804 KB Output is correct
30 Correct 0 ms 7804 KB Output is correct
31 Correct 0 ms 7804 KB Output is correct
32 Correct 0 ms 7804 KB Output is correct
33 Correct 0 ms 7804 KB Output is correct
34 Correct 0 ms 7804 KB Output is correct
35 Correct 0 ms 7804 KB Output is correct
36 Correct 0 ms 7804 KB Output is correct
37 Correct 0 ms 7804 KB Output is correct
38 Correct 0 ms 7804 KB Output is correct
39 Correct 19 ms 7944 KB Output is correct
40 Execution timed out 3000 ms 12440 KB Execution timed out
41 Execution timed out 3000 ms 27092 KB Execution timed out
42 Execution timed out 3000 ms 26828 KB Execution timed out
43 Correct 0 ms 7804 KB Output is correct
44 Execution timed out 3000 ms 25772 KB Execution timed out
45 Execution timed out 3000 ms 26564 KB Execution timed out
46 Execution timed out 3000 ms 10492 KB Execution timed out
47 Execution timed out 3000 ms 27092 KB Execution timed out
48 Execution timed out 3000 ms 26696 KB Execution timed out
49 Correct 56 ms 10960 KB Output is correct
50 Execution timed out 3000 ms 19304 KB Execution timed out
51 Correct 59 ms 10960 KB Output is correct
52 Execution timed out 3000 ms 27092 KB Execution timed out
53 Execution timed out 3000 ms 27092 KB Execution timed out
54 Execution timed out 3000 ms 24584 KB Execution timed out
55 Correct 136 ms 8340 KB Output is correct
56 Correct 89 ms 8208 KB Output is correct
57 Correct 29 ms 8076 KB Output is correct
58 Correct 0 ms 7944 KB Output is correct
59 Correct 29 ms 8076 KB Output is correct
60 Correct 3 ms 7944 KB Output is correct
61 Correct 139 ms 8340 KB Output is correct
62 Correct 0 ms 7804 KB Output is correct
63 Correct 113 ms 8208 KB Output is correct
64 Correct 0 ms 7944 KB Output is correct
65 Correct 83 ms 8076 KB Output is correct
66 Correct 63 ms 8076 KB Output is correct
67 Correct 66 ms 8076 KB Output is correct
68 Correct 3 ms 7944 KB Output is correct
69 Correct 3 ms 7944 KB Output is correct
70 Correct 3 ms 7944 KB Output is correct
71 Correct 6 ms 7936 KB Output is correct
72 Correct 3 ms 7944 KB Output is correct
73 Correct 26 ms 7944 KB Output is correct
74 Correct 0 ms 7944 KB Output is correct
75 Execution timed out 3000 ms 28676 KB Execution timed out
76 Execution timed out 3000 ms 22208 KB Execution timed out
77 Correct 1539 ms 10960 KB Output is correct
78 Correct 53 ms 10960 KB Output is correct
79 Correct 79 ms 10960 KB Output is correct
80 Execution timed out 3000 ms 28676 KB Execution timed out
81 Correct 59 ms 8076 KB Output is correct
82 Execution timed out 3000 ms 26564 KB Execution timed out
83 Correct 56 ms 10960 KB Output is correct
84 Execution timed out 3000 ms 23924 KB Execution timed out
85 Execution timed out 3000 ms 19172 KB Execution timed out
86 Execution timed out 3000 ms 19304 KB Execution timed out
87 Correct 139 ms 10960 KB Output is correct
88 Correct 109 ms 10960 KB Output is correct
89 Execution timed out 3000 ms 28676 KB Execution timed out
90 Execution timed out 3000 ms 28676 KB Execution timed out
91 Execution timed out 3000 ms 28676 KB Execution timed out
92 Correct 96 ms 10960 KB Output is correct
93 Execution timed out 3000 ms 19172 KB Execution timed out
94 Execution timed out 3000 ms 28676 KB Execution timed out
95 Execution timed out 3000 ms 28676 KB Execution timed out