Submission #416067

#TimeUsernameProblemLanguageResultExecution timeMemory
416067Pichon5Paths (BOI18_paths)C++17
0 / 100
356 ms9440 KiB
#include<bits/stdc++.h> #define ll long long int #define pb push_back #define vi vector<int> #define vll vector<ll> #define ff first #define ss second #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //"\n" __builtin_popcount using namespace std; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") const int tam=300005; int G[tam][3]; int C[tam]; int main(){ int n,m,k,x,a,b; cin>>n>>m>>k; for(int i=1;i<=n;i++){ cin>>x; C[i]=x-1; } for(int i=0;i<m;i++){ cin>>a>>b; G[a][C[b]]++; G[b][C[a]]++; } ll res=0; for(int i=1;i<=n;i++){ res+=G[i][0]+G[i][1]+G[i][2]; res-=G[i][C[i]]; if(C[i]==0)res+=2*G[i][1]*G[i][2]; if(C[i]==1)res+=2*G[i][0]*G[i][2]; if(C[i]==2)res+=2*G[i][0]*G[i][1]; } cout<<res<<endl; return 0; }

Compilation message (stderr)

paths.cpp:12: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   12 | #pragma GCC optimization ("O3")
      | 
paths.cpp:13: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   13 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...