Submission #1149146


Source Code Expand

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, m; cin >> n >> m;
    int a[110], b[110];
    rep(i,0,m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    bool covered[110] = {};
    int ans = 0;
    rep(i,0,n) {
        if(covered[i]) continue;
        int r = -1;
        rep(j,0,m) {
            if(a[j] <= i && i <= b[j]) {
                r = max(r, b[j]);
            }
        }
        if(r == -1) {
            cout << "Impossible" << endl;
            return 0;
        }
        repq(j,i,r) covered[j] = true;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - 権力
User tsutaj
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2036 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