Submission #1564979


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N, M;
  cin >> N >> M;
  vector< int > ev[100];
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    ev[a].push_back(b + 1);
  }
  int dp[101];
  fill_n(dp, 101, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(auto &to : ev[i]) {
      for(int j = i + 1; j <= to; j++) {
        dp[j] = min(dp[j], dp[i] + 1);
      }
    }
  }

  if(dp[N] == INF) puts("Impossible");
  else cout << dp[N] << endl;
}

Submission Info

Submission Time
Task D - 権力
User ei13333
Language C++14 (GCC 5.4.1)
Score 100
Code Size 561 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 53
Set Name Test Cases
All 00_sample_1, 00_sample_2, 00_teuchi_1, 00_teuchi_2, 00_teuchi_3, 00_teuchi_4, 10_max1_06, 10_max1_07, 10_max1_08, 10_max1_09, 10_max1_10, 10_max1_11, 10_max1_12, 10_max2_13, 10_max2_14, 10_max2_15, 10_max2_16, 10_max2_17, 10_max2_18, 10_max2_19, 10_max2_20, 10_max2_21, 10_max2_22, 10_min_00, 10_min_01, 10_min_02, 10_min_03, 10_min_04, 10_min_05, 10_rand_27, 10_rand_28, 10_rand_29, 10_rand_30, 10_rand_31, 10_rand_32, 10_rand_33, 10_rand_34, 10_rand_35, 10_rand_36, 10_rand_37, 10_rand_38, 10_rand_39, 10_rand_40, 10_rand_41, 10_rand_42, 10_rand_43, 10_rand_44, 10_rand_45, 10_rand_46, 10_unif_23, 10_unif_24, 10_unif_25, 10_unif_26
Case Name Status Exec Time Memory
00_sample_1 AC 1 ms 256 KB
00_sample_2 AC 1 ms 256 KB
00_teuchi_1 AC 1 ms 256 KB
00_teuchi_2 AC 1 ms 256 KB
00_teuchi_3 AC 1 ms 256 KB
00_teuchi_4 AC 1 ms 256 KB
10_max1_06 AC 1 ms 256 KB
10_max1_07 AC 1 ms 256 KB
10_max1_08 AC 1 ms 256 KB
10_max1_09 AC 1 ms 256 KB
10_max1_10 AC 1 ms 256 KB
10_max1_11 AC 1 ms 256 KB
10_max1_12 AC 1 ms 256 KB
10_max2_13 AC 1 ms 256 KB
10_max2_14 AC 1 ms 256 KB
10_max2_15 AC 1 ms 256 KB
10_max2_16 AC 1 ms 256 KB
10_max2_17 AC 1 ms 256 KB
10_max2_18 AC 1 ms 256 KB
10_max2_19 AC 1 ms 256 KB
10_max2_20 AC 1 ms 256 KB
10_max2_21 AC 1 ms 256 KB
10_max2_22 AC 1 ms 256 KB
10_min_00 AC 1 ms 256 KB
10_min_01 AC 1 ms 256 KB
10_min_02 AC 1 ms 256 KB
10_min_03 AC 1 ms 256 KB
10_min_04 AC 1 ms 256 KB
10_min_05 AC 1 ms 256 KB
10_rand_27 AC 1 ms 256 KB
10_rand_28 AC 1 ms 256 KB
10_rand_29 AC 1 ms 256 KB
10_rand_30 AC 1 ms 256 KB
10_rand_31 AC 1 ms 256 KB
10_rand_32 AC 1 ms 256 KB
10_rand_33 AC 1 ms 256 KB
10_rand_34 AC 1 ms 256 KB
10_rand_35 AC 1 ms 256 KB
10_rand_36 AC 1 ms 256 KB
10_rand_37 AC 1 ms 256 KB
10_rand_38 AC 1 ms 256 KB
10_rand_39 AC 1 ms 256 KB
10_rand_40 AC 1 ms 256 KB
10_rand_41 AC 1 ms 256 KB
10_rand_42 AC 1 ms 256 KB
10_rand_43 AC 1 ms 256 KB
10_rand_44 AC 1 ms 256 KB
10_rand_45 AC 1 ms 256 KB
10_rand_46 AC 1 ms 256 KB
10_unif_23 AC 1 ms 256 KB
10_unif_24 AC 1 ms 256 KB
10_unif_25 AC 1 ms 256 KB
10_unif_26 AC 1 ms 256 KB