Submission #563565

# Submission time Handle Problem Language Result Execution time Memory
563565 2022-05-17T14:03:34 Z Karliver Paths (BOI18_paths) C++17
20 / 100
203 ms 24272 KB
#include <bits/stdc++.h>

using namespace std;
const int N = 3e5 + 10;


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#define sz(x) int(x.size())
template<typename T> void ckmi(T &a, T b) {
	a = (b < a ? b : a);
}

int n, m ,k;
vector<int> g[N];
int cnt[N][3];
long long res = 0;
int A[N];
bool vis[N];
void dfs(int v, int mask = 0) {
	mask |= (1 << A[v]);
	res += 1;
	for(auto c : g[v]) {
		if((mask & (1 << A[c])))continue;
		dfs(c, mask);
	}
}
void test_case() {
	
	cin >> n >> m >> k;
	
	for(int j = 0;j < n;++j) cin >> A[j], --A[j];
	for(int i = 0;i < m;++i) {
		int a, b;
		cin >> a >> b;
		--a;--b;
		if(A[a] == A[b])continue;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	for(int j = 0;j < n;++j) res += int(g[j].size());
	
	for(int j = 0;j < n;++j) {
		for(auto c : g[j]) cnt[j][A[c]] += 1;
	}
	
	for(int j = 0;j < n;++j) {
		for(auto c : g[j]) {
			res += cnt[c][A[c] ^ 3 ^ A[j]];
		}
	}
	
	cout << res << '\n';
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt;
	tt = 1;
	//cin >> tt;
	
	for(int p = 1;p <= tt;++p) {
		//cout << "Case #" << p << ": ";
		test_case();
	}
	
		
	return 0;
}
  
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 11968 KB Output is correct
2 Correct 49 ms 11660 KB Output is correct
3 Correct 176 ms 23488 KB Output is correct
4 Correct 87 ms 13600 KB Output is correct
5 Correct 51 ms 10800 KB Output is correct
6 Correct 126 ms 20420 KB Output is correct
7 Correct 193 ms 23444 KB Output is correct
8 Correct 203 ms 24272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Incorrect 20 ms 9160 KB Output isn't correct
3 Halted 0 ms 0 KB -