QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#711891#8333. Giftdgme-syz#Compile Error//C++231.9kb2024-11-05 13:52:502024-11-05 13:52:53

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 13:52:53]
  • 评测
  • [2024-11-05 13:52:50]
  • 提交

answer

const int N = 2e5 + 10;

std::vector<int>e[N];
int num[N], low[N], dcc[N];
int dcc_cnt, n, m, dfn;
std::stack<int>stk;
void tarjan(int u, int fa) {
	low[u] = num[u] = ++dfn;
	stk.push(u);
	for (auto& v : e[u]) {
		if (v == fa) continue;
		if (!num[v]) {
			tarjan(v, u);
			low[u] = std::min(low[u], low[v]);
		}
		else {
			low[u] = std::min(low[u], num[v]);
		}
	}
	if (low[u] == num[u]) {
		++dcc_cnt;
		while (1) {
			int v = stk.top(); stk.pop();
			dcc[v] = dcc_cnt;
			if (u == v) break;
		}
	}
}
int deg[N];
void solve() {
	std::cin >> n;

	std::set<pii>edge;

	for (int i = 1; i <= n; ++i) {
		int u, v;
		std::cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);

		deg[u]++; deg[v]++;
		edge.insert({ u,v });
		edge.insert({ v,u });
	}

	tarjan(1, 1);

	std::vector<std::vector<int>>d(dcc_cnt + 1);
	for (int i = 1; i <= n; ++i) {
		d[dcc[i]].push_back(i);
	}

	std::set<int>c;
	for (int i = 1; i <= dcc_cnt; ++i) {
		if (d[i].size() > 1) {
			for (auto& x : d[i]) {
				c.insert(x);
			}
			break;
		}
	}

	std::vector<int>cnt; 
	for (int i = 1; i <= n; ++i) {
		if(deg[i] == 5) cnt.push_back(i);
	}

	int res = 0;
	for (int i = 1; i <= n; ++i) {
		if (deg[i] == 5) continue;

		else if (deg[i] == 4) {
			if (cnt.size() == 1) {
				if (edge.count({ cnt[0],i }) && c.count(cnt[0]) && c.count(i)) {
					++res;
				}
			}
			else if (cnt.empty()) {
				if (c.count(i)) res += 2;
			}
		}

		else {
			if (cnt.size() == 1) {
				if (c.count(cnt[0])) res += 2;
			}
			else if (cnt.size() == 2) {
				if (edge.count({ cnt[0],cnt[1] }) && c.count(cnt[0]) && c.count(cnt[1])) {
					++res;
				}
			}
			else if (cnt.empty()) {
				res += c.size();
			}
		}
	}

	std::cout << res << "\n";
}


signed main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	std::cout.tie(0);

	int t = 1;
	//std::cin >> t;

	while (t--) {
		solve();
	}
};

Details

answer.code:3:6: error: ‘vector’ in namespace ‘std’ does not name a template type
    3 | std::vector<int>e[N];
      |      ^~~~~~
answer.code:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
  +++ |+#include <vector>
    1 | const int N = 2e5 + 10;
answer.code:6:6: error: ‘stack’ in namespace ‘std’ does not name a template type
    6 | std::stack<int>stk;
      |      ^~~~~
answer.code:1:1: note: ‘std::stack’ is defined in header ‘<stack>’; did you forget to ‘#include <stack>’?
  +++ |+#include <stack>
    1 | const int N = 2e5 + 10;
answer.code: In function ‘void tarjan(int, int)’:
answer.code:9:9: error: ‘stk’ was not declared in this scope; did you mean ‘std’?
    9 |         stk.push(u);
      |         ^~~
      |         std
answer.code:10:24: error: ‘e’ was not declared in this scope
   10 |         for (auto& v : e[u]) {
      |                        ^
answer.code:14:39: error: ‘min’ is not a member of ‘std’
   14 |                         low[u] = std::min(low[u], low[v]);
      |                                       ^~~
answer.code:17:39: error: ‘min’ is not a member of ‘std’
   17 |                         low[u] = std::min(low[u], num[v]);
      |                                       ^~~
answer.code: In function ‘void solve()’:
answer.code:31:14: error: ‘cin’ is not a member of ‘std’
   31 |         std::cin >> n;
      |              ^~~
answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
  +++ |+#include <iostream>
    1 | const int N = 2e5 + 10;
answer.code:33:14: error: ‘set’ is not a member of ‘std’
   33 |         std::set<pii>edge;
      |              ^~~
answer.code:1:1: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’?
  +++ |+#include <set>
    1 | const int N = 2e5 + 10;
answer.code:33:18: error: ‘pii’ was not declared in this scope
   33 |         std::set<pii>edge;
      |                  ^~~
answer.code:33:22: error: ‘edge’ was not declared in this scope
   33 |         std::set<pii>edge;
      |                      ^~~~
answer.code:37:22: error: ‘cin’ is not a member of ‘std’
   37 |                 std::cin >> u >> v;
      |                      ^~~
answer.code:37:22: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code:38:17: error: ‘e’ was not declared in this scope
   38 |                 e[u].push_back(v);
      |                 ^
answer.code:48:14: error: ‘vector’ is not a member of ‘std’
   48 |         std::vector<std::vector<int>>d(dcc_cnt + 1);
      |              ^~~~~~
answer.code:48:14: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
answer.code:48:26: error: ‘vector’ is not a member of ‘std’
   48 |         std::vector<std::vector<int>>d(dcc_cnt + 1);
      |                          ^~~~~~
answer.code:48:26: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
answer.code:48:33: error: expected primary-expression before ‘int’
   48 |         std::vector<std::vector<int>>d(dcc_cnt + 1);
      |                                 ^~~
answer.code:50:17: error: ‘d’ was not declared in this scope
   50 |                 d[dcc[i]].push_back(i);
      |                 ^
answer.code:53:14: error: ‘set’ is not a member of ‘std’
   53 |         std::set<int>c;
      |              ^~~
answer.code:53:14: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’?
answer.code:53:18: error: expected primary-expression before ‘int’
   53 |         std::set<int>c;
      |                  ^~~
answer.code:55:21: error: ‘d’ was not declared in this scope
   55 |                 if (d[i].size() > 1) {
      |                     ^
answer.code:57:33: error: ‘c’ was not declared in this scope
   57 |                                 c.insert(x);
      |                                 ^
answer.code:63:14: error: ‘vector’ is not a member of ‘std’
   63 |         std::vector<int>cnt;
      |              ^~~~~~
answer.code:63:14: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
answer.code:63:21: error: expected primary-expression before ‘int’
   63 |         std::vector<int>cnt;
      |                     ^~~
answer.code:65:33: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   65 |                 if(deg[i] == 5) cnt.push_back(i);
      |                                 ^~~
      |                                 int
answer.code:73:29: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   73 |                         if (cnt.size() == 1) {
      |                             ^~~
      |                             int
answer.code:74:65: error: ‘c’ was not declared in this scope
   74 |                                 if (edge.count({ cnt[0],i }) && c.count(cnt[0]) && c.count(i)) {
      |                         ...