Submission #952850

#TimeUsernameProblemLanguageResultExecution timeMemory
952850koukirocksPaths (BOI18_paths)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> #define speed ios_base::sync_with_stdio(0); cin.tie(0) #define all(x) (x).begin(),(x).end() #define F first #define S second namespace{using namespace std;} typedef long long ll; typedef double db; typedef long double ldb; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MAX=15+10,P=1e9+7; const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f; int n,m,k; int clr[MAX]; vector<int> G[MAX]; int main() { speed; cin>>n>>m>>k; for (int i=1;i<=n;i++) { cin>>clr[i]; } for (int i=0;i<m;i++) { int a,b; cin>>a>>b; G[a].push_back(b); G[b].push_back(a); } ll l2=0; ll l3=0; for (int i=1;i<=n;i++) { ll cal[4]={0,0,0,0}; for (int u:G[i]) cal[clr[u]]++; // for (int c=1;c<=k;c++) cout<<cal[c]<<" "; // cout<<"\n"; if (clr[i]==1) { l2+=cal[2]+cal[3]; l3+=cal[2]*cal[3]; } else if (clr[i]==2) { l2+=cal[1]+cal[3]; l3+=cal[1]*cal[3]; } else { l2+=cal[2]+cal[1]; l3+=cal[2]*cal[1]; } // cout<<l2<<" "<<l3<<"\n"; } cout<<l2+2*l3<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...