QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#244562#4938. Writing TasksckisekiCompile Error//C++143.7kb2023-11-09 11:53:182023-11-09 11:53:18

Judging History

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

  • [2023-11-09 11:53:18]
  • 评测
  • [2023-11-09 11:53:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define iter(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb emplace_back
#define ff first
#define ss second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U>
void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
	while(l != r) cout << *l << " ", l++;
	cout << endl;	
}
#else
#define debug(...) void()
#define pary(...) void()
#endif

template<class A, class B>
ostream& operator<<(ostream& o, pair<A, B> p){
	return o << '(' << p.ff << ',' << p.ss << ')';
}
#define maxn 200005 
vector<int> ga[maxn], gc[maxn], gt[maxn], g[maxn];
bool vis[maxn];
vector<int> qq;
void dfs(int n, int &siz) {
	siz++; qq.pb(n);
	vis[n] = 1;
	for (int v:g[n]) {
		if (!vis[v]) {
			dfs(v, siz);
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int siza, sizc, sizt;
	cin >> siza >> sizc >> sizt;
	for (int i = 1;i <= siza;i++) {
		//ac
		int li; cin >> li;
		for (int j = 0;j < li;j++) {
			int x;
			cin >> x;
			ga[i].push_back(x);
		}
	}
	for (int i = 1;i <= siza;i++) {
		//at
		int li; cin >> li;
		for (int j = 0;j < li;j++) {
			int x;
			cin >> x;
			gt[x].push_back(i);
		}
	}
	for (int i = 1;i <= sizc;i++) {
		//ct
		int li; cin >> li;
		for (int j = 0;j < li;j++) {
			int x;
			cin >> x;
			gc[i].push_back(x);
		}
	}
	map<vector<int>, int> mp;	
	int n = 1;
	for (int a = 1;a <= siza;a++) {
		for (int c:ga[a]){
			int cnt = 0;
			for (int t:gc[c]) {
				for (int ta:gt[t]) {
					if (ta == a) {
						vector<int> cy = {a, c, t};	
						cnt++;
						if (!mp[cy]) {
							mp[cy] = n++;
						}
						break;
					}
				}	
			}
			if (cnt == 2) {
				vector<int> vu = {a, c, gc[c][0]}, vv = {a, c, gc[c][1]};
				int u = mp[vu], v = mp[vv];
				g[u].push_back(v);
				g[v].push_back(u);
			}
		}
	}

	for (int c = 1;c <= sizc;c++) {
		for (int t:gc[c]){
			int cnt = 0;
			for (int a:gt[t]) {
				for (int tc:ga[a]) {
					if (tc == c) {
						vector<int> cy = {a, c, t};	
						cnt++;
						if (!mp[cy]) {
							mp[cy] = n++;
						}
						break;
					}
				}	
			}
			if (cnt == 2) {
				vector<int> vu = {gt[t][0], c, t}, vv = {gt[t][1], c, t};
				int u = mp[vu], v = mp[vv];
				g[u].push_back(v);
				g[v].push_back(u);
			}
		}
	}
	for (int t = 1;t <= sizt;t++) {
		for (int a:gt[t]){
			int cnt = 0;
			for (int c:ga[a]) {
				for (int tt:gc[c]) {
					if (tt == t) {
						vector<int> cy = {a, c, t};	
						cnt++;
						if (!mp[cy]) {
							mp[cy] = n++;
						}
						break;
					}
				}	
			}
			if (cnt == 2) {
				vector<int> vu = {a, ga[a][0], t}, vv = {a, ga[a][1], t};
				int u = mp[vu], v = mp[vv];
				g[u].push_back(v);
				g[v].push_back(u);
			}
		}
	}
	/*
	for (auto [v, ind]:mp) {
		pary(v.begin(), v.end());
		debug(ind);
		debug();
	}
	for (int i = 1;i <= n;i++) {
		cout << i << ": ";
		pary(g[i].begin(), g[i].end());
		
	}
	*/
	int ans = 0;
	for (int i = 1;i < n;i++) {
		if (g[i].size() == 3 && !vis[i]) {
qq.clear();
			int siz = 0;
			dfs(i, siz);
			if (siz == 8) {
for (auto tt:qq) cout << tt << “\n”;
assert(false);
}
			else ans += 3;
		}
	}	
	for (int i = 1;i < n;i++) {
		if (g[i].size() == 1 && !vis[i]) {
			int siz = 0;
			dfs(i, siz);
			ans += (siz + 1) / 2;
		}
	}
	for (int i = 1;i < n;i++) {
		if (g[i].size() == 2 && !vis[i]) {
			int siz = 0;
			dfs(i, siz);
			ans += siz / 2;
		}
	}
	for (int i = 1;i < n;i++) {
		if (g[i].size() == 0 && !vis[i]) ans++;
	}
	cout << ans << "\n";
}

Details

answer.code:169:32: error: extended character “ is not valid in an identifier
  169 | for (auto tt:qq) cout << tt << “\n”;
      |                                ^
answer.code:169:33: error: stray ‘\’ in program
  169 | for (auto tt:qq) cout << tt << “\n”;
      |                                 ^
answer.code:169:34: error: extended character ” is not valid in an identifier
  169 | for (auto tt:qq) cout << tt << “\n”;
      |                                  ^
answer.code: In function ‘int main()’:
answer.code:169:32: error: ‘“’ was not declared in this scope
  169 | for (auto tt:qq) cout << tt << “\n”;
      |                                ^