結果

問題 No.479 頂点は要らない
ユーザー ikdikd
提出日時 2017-01-28 02:27:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 82 ms / 1,500 ms
コード長 901 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 63,356 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2023-08-25 12:40:22
合計ジャッジ時間 4,086 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 82 ms
9,128 KB
testcase_27 AC 81 ms
9,392 KB
testcase_28 AC 69 ms
10,112 KB
testcase_29 AC 68 ms
7,428 KB
testcase_30 AC 67 ms
7,408 KB
testcase_31 AC 68 ms
7,724 KB
testcase_32 AC 68 ms
7,408 KB
testcase_33 AC 65 ms
7,856 KB
testcase_34 AC 71 ms
7,892 KB
testcase_35 AC 64 ms
6,732 KB
testcase_36 AC 35 ms
5,204 KB
testcase_37 AC 70 ms
8,120 KB
testcase_38 AC 59 ms
7,200 KB
testcase_39 AC 41 ms
6,492 KB
testcase_40 AC 50 ms
7,656 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:36: warning: narrowing conversion of ‘g[b].std::vector<E>::size()’ from ‘std::vector<E>::size_type’ {aka ‘long unsigned int’} to ‘int’ inside { } [-Wnarrowing]
       g[a].push_back(E{b, g[b].size()});
                           ~~~~~~~~~^~
main.cpp:19:38: warning: narrowing conversion of ‘(g[a].std::vector<E>::size() - 1)’ from ‘std::vector<E>::size_type’ {aka ‘long unsigned int’} to ‘int’ inside { } [-Wnarrowing]
       g[b].push_back(E{a, g[a].size()-1});
                           ~~~~~~~~~~~^~

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

struct E{
   int to, rev;
};

signed main(){

   int N, M;
   cin>> N>> M;
   vector<E> g[N];
   for(int i=0; i<M; i++){
      int a, b;
      cin>> a>> b;
      g[a].push_back(E{b, g[b].size()});
      g[b].push_back(E{a, g[a].size()-1});
   }

   vector<int> v;
   for(int n=N-1; n>=0; n--){
      bool y=false;
      for(auto e: g[n]){
         y|=(e.to>n);
      }
      v.push_back(y);
      if(y){
         for(auto &e: g[n]){
            if(e.to<0) continue;
            g[e.to][e.rev].to=-1;
            e.to=-1;
         }
      }else{

      }
   }

   bool Lz=true;
   for(int d: v){
      if(d==0){
         if(Lz){

         }else{
            cout<< d;
         }
      }else{
         if(Lz){
            cout<< d;
            Lz=false;
         }else{
            cout<< d;
         }
      }
   }cout<< endl;

   return 0;
}
0