結果

問題 No.92 逃走経路
コンテスト
ユーザー kurenai3110
提出日時 2016-06-21 18:44:43
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 989 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 557 ms
コンパイル使用メモリ 86,400 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2026-04-28 02:30:16
合計ジャッジ時間 7,502 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other WA * 3 TLE * 1 -- * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:47:23: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]', declared with attribute 'nodiscard' [-Wunused-result]
   47 |                 unique(kouho.begin(), kouho.end());
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 from main.cpp:3:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:875:5: note: declared here
  875 |     unique(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a,b,c;
	a.resize(m);
	b.resize(m);
	c.resize(m);
	for (int i = 0; i < m; i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<int> waru;
	waru.resize(k);
	vector<int> kouho;
	for (int i = 0; i < k; i++){
		cin >> waru[i];
	}
	
	for (int i = 0; i < m; i++){
		if (c[i] == waru[0]){
			kouho.push_back(a[i]);
			kouho.push_back(b[i]);
		}
	}
	for(int j=1;j<k;j++){
		for (int i = 0; i < m; i++){
			if (c[i] == waru[j]){
				for (int h = 0; h < kouho.size(); h++){
					if (kouho[h] == a[i]){
						kouho.erase(kouho.begin() + h);
						kouho.push_back(b[i]);
					}
					else if (kouho[h] == b[i]){
						kouho.erase(kouho.begin() + h);
						kouho.push_back(a[i]);
					}
				}
			}
		}
		sort(kouho.begin(), kouho.end());
		unique(kouho.begin(), kouho.end());
	}

	for (int i = 0; i < kouho.size(); i++){
		cout << kouho[i] << endl;
	}
	return 0;
}

0