結果

問題 No.479 頂点は要らない
ユーザー tnakao0123tnakao0123
提出日時 2017-01-29 01:05:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 58 ms / 1,500 ms
コード長 1,069 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-08-25 13:34:57
合計ジャッジ時間 3,912 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 57 ms
4,380 KB
testcase_27 AC 58 ms
4,484 KB
testcase_28 AC 52 ms
4,440 KB
testcase_29 AC 53 ms
4,380 KB
testcase_30 AC 52 ms
4,376 KB
testcase_31 AC 51 ms
4,384 KB
testcase_32 AC 54 ms
4,380 KB
testcase_33 AC 47 ms
4,396 KB
testcase_34 AC 52 ms
4,380 KB
testcase_35 AC 51 ms
4,376 KB
testcase_36 AC 30 ms
4,376 KB
testcase_37 AC 49 ms
4,432 KB
testcase_38 AC 43 ms
4,380 KB
testcase_39 AC 31 ms
4,380 KB
testcase_40 AC 35 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 479.cc: No.479 頂点は要らない - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

bool vs[MAX_N];
pii es[MAX_M];

/* subroutines */

/* main */

int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    es[i] = pii(b, a);
  }
  sort(es, es + m, greater<pii>());

  for (int i = 0; i < m; i++) {
    int &bi = es[i].first, &ai = es[i].second;
    if (! vs[bi]) vs[ai] = true;
  }

  bool zf = false;
  for (int i = n - 1; i >= 0; i--) {
    if (vs[i] || zf) {
      printf("%d", vs[i]);
      zf = true;
    }
  }
  putchar('\n');
  return 0;
}
0