提出 #462617


ソースコード 拡げる

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

int main() {
	int n;
	cin >> n;
	map<string, int> m;
	vector<pair<string, int>> val;
	for (size_t i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		val.push_back(make_pair(s, -1));
		m[s] = i;
	}
	bool bad = false;
	for (size_t i = 0; i < n; i++)
	{
		string u, v, s;
		cin >> u >> s >> s >> v >> s;
		auto& iti = val[i];
		auto& itu = val[m[u]];
		if (iti.second == -1)iti.second = i;
		if (itu.second == -1)itu.second = m[u];
		if (v == "good") {
			int uni = itu.second;
			int unito = iti.second;
			if (uni < unito)swap(uni, unito);
			for (pair<string, int>& p : val)
			{
				if (p.second == uni) {
					p.second = unito;
				}
			}
		}
		else if (v == "bad") {
			if (iti.second == itu.second)bad = true;
		}
	}
	vector<string> goods;
	vector<string> zero, one;
	int zn = -1, on = -1;
	for (pair<string, int>& p : val)
	{
		if (p.second == -1) {
			goods.push_back(p.first);
		}
		else {
			if (zn == -1 || zn == p.second) {
				zn = p.second;
				zero.push_back(p.first);
			}
			else if (on == -1 || on == p.second) {
				on = p.second;
				one.push_back(p.first);
			}
			else {
				bad = true;
			}
		}
	}
	if (bad)cout << "No answers" << endl;
	else {
		bool zeroisbad = false;
		if (zero.size() == one.size()) {
			if (zero.size() != 0) {
				auto z = min_element(zero.begin(), zero.end());
				auto o = min_element(one.begin(), one.end());
				if (*z > *o)zeroisbad = true;
			}
		}
		else {
			if (zero.size() < one.size()) {
				zeroisbad = true;
			}
		}
		if (zeroisbad)swap(zero, one);
		goods.assign(zero.begin(), zero.end());
		if (goods.size() == 0) {
			cout << "No answers" << endl;
		}
		else {
			sort(goods.begin(), goods.end());
			for (string s : goods) {
				cout << s << endl;
			}
		}
	}
	return 0;
}

提出情報

提出日時
問題 C - 酒場の冒険者たち
ユーザ toikage
言語 C++14 (Clang++ 3.4)
得点 0
コード長 1938 Byte
結果 WA
実行時間 27 ms
メモリ 928 KiB

ジャッジ結果

セット名 All
得点 / 配点 0 / 100
結果
AC × 20
WA × 7
セット名 テストケース
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_max_00.txt, 01_max_01.txt, 05_corner_00.txt, 05_corner_01.txt, 05_corner_02.txt, 10_min_00.txt, 10_min_01.txt, 10_min_02.txt, 10_wrong_answer_00.txt, 20_max_00.txt, 20_max_01.txt, 20_max_02.txt, 90_random_00.txt, 90_random_01.txt, 90_random_02.txt, 90_random_03.txt, 90_random_04.txt, 90_random_05.txt, 90_random_06.txt, 90_random_07.txt, 90_random_08.txt, 90_random_09.txt, 99_medium_00.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 27 ms 800 KiB
00_sample_01.txt AC 26 ms 920 KiB
00_sample_02.txt AC 23 ms 924 KiB
00_sample_03.txt AC 25 ms 796 KiB
01_max_00.txt WA 25 ms 800 KiB
01_max_01.txt AC 26 ms 800 KiB
05_corner_00.txt AC 26 ms 736 KiB
05_corner_01.txt AC 26 ms 920 KiB
05_corner_02.txt WA 27 ms 796 KiB
10_min_00.txt AC 27 ms 928 KiB
10_min_01.txt AC 25 ms 916 KiB
10_min_02.txt AC 26 ms 800 KiB
10_wrong_answer_00.txt WA 27 ms 808 KiB
20_max_00.txt AC 26 ms 796 KiB
20_max_01.txt AC 26 ms 796 KiB
20_max_02.txt AC 23 ms 792 KiB
90_random_00.txt AC 26 ms 800 KiB
90_random_01.txt AC 26 ms 732 KiB
90_random_02.txt AC 25 ms 912 KiB
90_random_03.txt AC 25 ms 916 KiB
90_random_04.txt WA 26 ms 808 KiB
90_random_05.txt WA 26 ms 916 KiB
90_random_06.txt AC 26 ms 792 KiB
90_random_07.txt AC 24 ms 920 KiB
90_random_08.txt WA 26 ms 924 KiB
90_random_09.txt AC 23 ms 924 KiB
99_medium_00.txt WA 25 ms 924 KiB