AtCoder Beginner Contest 054

Submission #1587728

Source codeソースコード

#include <bits/stdc++.h>
#include <regex>
using namespace std;
typedef long long ll;

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

const int VMAX = 100;

bool dist[VMAX][VMAX] = {};

signed main() {
	int V, E;
	cin >> V >> E;

	for (size_t i = 0; i < E ; i++) {
		for (size_t j = 0; j < E ; j++) {
			dist[i][j] = false;
			dist[j][i] = false;
		}
	}

	for (int i = 0; i < E; ++i) {
		int s, t;
		cin >> s >> t;
		dist[s - 1][t - 1] = true;
		dist[t - 1][s - 1] = true;
	}
	std::vector<int> v = {};
	for (size_t i = 0; i < V; i++) {
		v.push_back(i);
	}

	int c = 0;
  do {
		if (v[0] != 0) {
			continue;
		}
		bool ok = true;
		for (size_t i = 1; i < V && ok; i++) {
			ok = dist[v[i - 1]][v[i]];
		}
		c += ok;
  } while (std::next_permutation(v.begin(), v.end()));
	cout << c << endl;
}

Submission

Task問題 C - One-stroke Path
User nameユーザ名 えるざっぷ
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 1124 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 256 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt
All 300 / 300 sample_01.txt,sample_02.txt,subtask_1_01.txt,subtask_1_02.txt,subtask_1_03.txt,subtask_1_04.txt,subtask_1_05.txt,subtask_1_06.txt,subtask_1_07.txt,subtask_1_08.txt,subtask_1_09.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 1 ms 256 KB
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 1 ms 256 KB
subtask_1_07.txt AC 1 ms 256 KB
subtask_1_08.txt AC 1 ms 256 KB
subtask_1_09.txt AC 1 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_13.txt AC 1 ms 256 KB