Submission #1971813


Source Code Expand

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

long long n, a[1000], cnt; bool used[1000]; vector<pair<int, int>>x; vector<int> X[6];

void dfs(int pos) {
	if (used[pos] == true) return;
	used[pos] = true;
	for (int i = 0; i < X[pos].size(); i++) dfs(X[pos][i]);
}

int main() {
	cin >> n; assert(n <= 5);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) x.push_back(make_pair(i, j)); }
	for (int i = 0; i < (1 << x.size()); i++) {
		for (int j = 0; j < 6; j++) { X[j].clear(); used[j] = false; }
		for (int j = 0; j < x.size(); j++) {
			if ((i / (1 << j)) % 2 == 0) continue;
			int a1 = x[j].first, a2 = x[j].second;
			X[a1].push_back(a2); X[a2].push_back(a1);
		}
		bool flag = false;
		for (int j = 0; j < n; j++) {
			if (a[j] != X[j].size()) flag = true;
		}
		dfs(0);
		for (int j = 0; j < n; j++) {
			if (used[j] == false) flag = true;
		}
		if (flag == false) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Submission Info

Submission Time
Task F - Unicyclic Graph Counting
User E869120
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1040 Byte
Status RE
Exec Time 304 ms
Memory 256 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3 All
Score / Max Score 0 / 0 200 / 200 0 / 200 0 / 300 0 / 300
Status
AC × 1
RE × 1
AC × 9
AC × 9
RE × 9
AC × 9
RE × 19
AC × 9
RE × 30
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
Subtask1 00_example_01.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt
Subtask2 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt, s2_09.txt, s2_10.txt, s2_11.txt, s2_12.txt, s2_13.txt, s2_14.txt, s2_15.txt, s2_16.txt
Subtask3 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt, s2_09.txt, s2_10.txt, s2_11.txt, s2_12.txt, s2_13.txt, s2_14.txt, s2_15.txt, s2_16.txt, s3_17.txt, s3_18.txt, s3_19.txt, s3_20.txt, s3_21.txt, s3_22.txt, s3_23.txt, s3_24.txt, s3_25.txt, s3_26.txt
All 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt, s2_09.txt, s2_10.txt, s2_11.txt, s2_12.txt, s2_13.txt, s2_14.txt, s2_15.txt, s2_16.txt, s3_17.txt, s3_18.txt, s3_19.txt, s3_20.txt, s3_21.txt, s3_22.txt, s3_23.txt, s3_24.txt, s3_25.txt, s3_26.txt, s4_27.txt, s4_28.txt, s4_29.txt, s4_30.txt, s4_31.txt, s4_32.txt, s4_33.txt, s4_34.txt, s4_35.txt, s4_36.txt, s4_37.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt RE 304 ms 256 KB
s1_01.txt AC 1 ms 256 KB
s1_02.txt AC 1 ms 256 KB
s1_03.txt AC 1 ms 256 KB
s1_04.txt AC 1 ms 256 KB
s1_05.txt AC 1 ms 256 KB
s1_06.txt AC 1 ms 256 KB
s1_07.txt AC 1 ms 256 KB
s1_08.txt AC 1 ms 256 KB
s2_09.txt RE 99 ms 256 KB
s2_10.txt RE 100 ms 256 KB
s2_11.txt RE 98 ms 256 KB
s2_12.txt RE 98 ms 256 KB
s2_13.txt RE 99 ms 256 KB
s2_14.txt RE 99 ms 256 KB
s2_15.txt RE 98 ms 256 KB
s2_16.txt RE 98 ms 256 KB
s3_17.txt RE 97 ms 256 KB
s3_18.txt RE 99 ms 256 KB
s3_19.txt RE 98 ms 256 KB
s3_20.txt RE 98 ms 256 KB
s3_21.txt RE 99 ms 256 KB
s3_22.txt RE 98 ms 256 KB
s3_23.txt RE 98 ms 256 KB
s3_24.txt RE 98 ms 256 KB
s3_25.txt RE 101 ms 256 KB
s3_26.txt RE 99 ms 256 KB
s4_27.txt RE 101 ms 256 KB
s4_28.txt RE 99 ms 256 KB
s4_29.txt RE 100 ms 256 KB
s4_30.txt RE 101 ms 256 KB
s4_31.txt RE 98 ms 256 KB
s4_32.txt RE 98 ms 256 KB
s4_33.txt RE 98 ms 256 KB
s4_34.txt RE 98 ms 256 KB
s4_35.txt RE 99 ms 256 KB
s4_36.txt RE 98 ms 256 KB
s4_37.txt RE 99 ms 256 KB