Submission #1565001


Source Code Expand

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

#define fs first
#define sc second

/*
class SegTree{
private:
	vector<ll> node;
	int n;
public:
	SegTree(vector<ll> a){
		n = 1;
		while(n < a.size()) n *= 2;
		node.resize(0, 2*n-1);
		FOR(i, a.size()){
			node[n+i-1] = a[i];
		}
		for(int i = n-1
	}
};
*/

int main(void){
	int N, M;
	int a[101] = {};
	cin >> N >> M;
	REP(i, M){
		int s, g;
		cin >> s >> g;
		a[s] = max(a[s], g);
	}
	int ll = 0, last = 1;
	int cnt = 0;
	while(last < N){
		int in = -1;
		FOR(i, ll, last+1){
			in = max(in, a[i]);
		}
		if(in <= last){
			cout << "Impossible" << endl;
			return 0;
		}
		cnt++;
		last = in;
	}
	cout << cnt << endl;
}

Submission Info

Submission Time
Task D - 権力
User maze1230
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1383 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 41
WA × 12
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 WA 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 WA 1 ms 256 KB
10_max2_17 WA 1 ms 256 KB
10_max2_18 WA 1 ms 256 KB
10_max2_19 WA 1 ms 256 KB
10_max2_20 AC 1 ms 256 KB
10_max2_21 AC 1 ms 256 KB
10_max2_22 WA 1 ms 256 KB
10_min_00 WA 1 ms 256 KB
10_min_01 WA 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 WA 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 WA 1 ms 256 KB
10_rand_46 AC 1 ms 256 KB
10_unif_23 WA 1 ms 256 KB
10_unif_24 AC 1 ms 256 KB
10_unif_25 WA 1 ms 256 KB
10_unif_26 AC 1 ms 256 KB