Submission #3154011


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int n;
	cin >> n;
	vs w;
	rep(i, 0, n) {
		string s;
		cin >> s;
		w.push_back(s);
	}
	string s0(w[0]);
	repv(i, w) {
		repv(j, w) {
			if (w[i] == w[j] && i != j) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	rep(i, 1, n) {
		string s1 = w[i];
		if (s0[s0.size() - 1] != s1[0]) {
			cout << "No" << endl;
			return 0;
		}
		s0 = s1;
	}
	cout << "Yes" << endl;
}

Submission Info

Submission Time
Task B - Shiritori
User taku0728
Language Python3 (3.4.3)
Score 0
Code Size 1731 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 200 max_1, max_2, max_3, max_4, min_1, no1_1, no1_2, no2_1, no2_2, random_1, random_2, sample_01, sample_02, sample_03, sample_04, yes_1, yes_2
Sample 0 / 0 sample_01, sample_02, sample_03, sample_04
Case Name Status Exec Time Memory
max_1
max_2
max_3
max_4
min_1
no1_1
no1_2
no2_1
no2_2
random_1
random_2
sample_01
sample_02
sample_03
sample_04
yes_1
yes_2