# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
391761 | ollel | Paths (BOI18_paths) | C++14 | 170 ms | 11000 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <bitset>
#include <iostream>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
#define rep(i,a,b) for(int i = a; i < b; i++)
int n,m,k;
vector<vi> adj;
vi clr;
const int maxN = 200;
ll ans = 0;
void get(int node, bitset<maxN> &visited, bitset<maxN> &clrs) {
ans++;
visited.flip(node);
clrs.flip(clr[node]);
// rep(i,0,10) cout << visited[i] << " ";
// cout<<endl;
// rep(i,0,10) cout << clrs[i] << " ";
// cout << endl;
rep(i,0,adj[node].size()) {
// cout << visited[adj[node][i]] << " " << clrs[clr[adj[node][i]]] << endl;
if ((!visited[adj[node][i]]) && (!clrs[clr[adj[node][i]]])) {
get(adj[node][i], visited, clrs);
}
}
visited.flip(node);
clrs.flip(clr[node]);
}
int main()
{
cin>>n>>m>>k;
adj.resize(n); clr.resize(n);
rep(i,0,n) cin >> clr[i];
int x,y;
rep(i,0,m) {
cin>>x>>y;x--;y--;
adj[x].push_back(y);
adj[y].push_back(x);
}
bitset<maxN> visited(0), clrs(0);
rep(i, 0, n) {
get(i, visited, clrs);
}
ans-=n;
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |