結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
ikd
|
| 提出日時 | 2017-01-28 02:27:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 1,500 ms |
| コード長 | 901 bytes |
| コンパイル時間 | 733 ms |
| コンパイル使用メモリ | 63,624 KB |
| 実行使用メモリ | 10,228 KB |
| 最終ジャッジ日時 | 2024-12-23 20:05:46 |
| 合計ジャッジ時間 | 3,004 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
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’ [-Wnarrowing]
18 | 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’ [-Wnarrowing]
19 | g[b].push_back(E{a, g[a].size()-1});
| ~~~~~~~~~~~^~
ソースコード
#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;
}
ikd