結果
| 問題 | 
                            No.479 頂点は要らない
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-13 19:00:19 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 43 ms / 1,500 ms | 
| コード長 | 617 bytes | 
| コンパイル時間 | 950 ms | 
| コンパイル使用メモリ | 82,044 KB | 
| 最終ジャッジ日時 | 2025-01-14 14:32:42 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 38 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
void solve() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::pair<int, int>> es(m);
    for (auto& [u, v] : es) std::cin >> u >> v;
    std::sort(es.rbegin(), es.rend());
    std::string ans(n, '0');
    for (auto [u, v] : es) {
        if (ans[u] == '0' && ans[v] == '0') ans[u] = '1';
    }
    while (ans.back() == '0') ans.pop_back();
    std::reverse(ans.begin(), ans.end());
    std::cout << ans << "\n";
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}