답안 #416075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416075 2021-06-01T22:28:56 Z Pichon5 Paths (BOI18_paths) C++17
70 / 100
666 ms 95916 KB
#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;
vll G[tam];
ll C[tam];
ll res=0;
ll dp[tam][32];
ll dfs(int nodo, int mask){
   if(__builtin_popcount(mask)==4)return 0;
   if(dp[nodo][mask]!=-1)return dp[nodo][mask];
   dp[nodo][mask]=0;
   for(auto it : G[nodo]){
      if(mask&(1<<C[it]))continue;
      dp[nodo][mask]+=1+dfs(it,mask|(1<<C[it]));
   }
   return dp[nodo][mask];
}
int  main(){
   fast
   ll n,m,k,x,a,b;
   memset(dp,-1,sizeof(dp));
   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].pb(b);
      G[b].pb(a);
   }
   for(int i=1;i<=n;i++){
      res+=dfs(i,(1<<C[i]));
   }
   cout<<res<<endl;
   
   return 0;
}

Compilation message

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")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 82488 KB Output is correct
2 Correct 57 ms 82424 KB Output is correct
3 Correct 55 ms 82412 KB Output is correct
4 Correct 54 ms 82500 KB Output is correct
5 Correct 58 ms 82436 KB Output is correct
6 Correct 48 ms 82440 KB Output is correct
7 Correct 55 ms 82440 KB Output is correct
8 Correct 52 ms 82500 KB Output is correct
9 Correct 56 ms 82408 KB Output is correct
10 Correct 56 ms 82432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 89652 KB Output is correct
2 Correct 131 ms 89656 KB Output is correct
3 Correct 631 ms 95360 KB Output is correct
4 Correct 230 ms 90856 KB Output is correct
5 Correct 192 ms 90820 KB Output is correct
6 Correct 440 ms 92936 KB Output is correct
7 Correct 468 ms 95300 KB Output is correct
8 Correct 537 ms 95912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 82488 KB Output is correct
2 Correct 57 ms 82424 KB Output is correct
3 Correct 55 ms 82412 KB Output is correct
4 Correct 54 ms 82500 KB Output is correct
5 Correct 58 ms 82436 KB Output is correct
6 Correct 48 ms 82440 KB Output is correct
7 Correct 55 ms 82440 KB Output is correct
8 Correct 52 ms 82500 KB Output is correct
9 Correct 56 ms 82408 KB Output is correct
10 Correct 56 ms 82432 KB Output is correct
11 Correct 163 ms 89652 KB Output is correct
12 Correct 131 ms 89656 KB Output is correct
13 Correct 631 ms 95360 KB Output is correct
14 Correct 230 ms 90856 KB Output is correct
15 Correct 192 ms 90820 KB Output is correct
16 Correct 440 ms 92936 KB Output is correct
17 Correct 468 ms 95300 KB Output is correct
18 Correct 537 ms 95912 KB Output is correct
19 Correct 174 ms 89692 KB Output is correct
20 Correct 119 ms 89660 KB Output is correct
21 Correct 492 ms 95344 KB Output is correct
22 Correct 210 ms 90892 KB Output is correct
23 Correct 200 ms 90828 KB Output is correct
24 Correct 463 ms 92824 KB Output is correct
25 Correct 475 ms 95264 KB Output is correct
26 Correct 558 ms 95916 KB Output is correct
27 Correct 151 ms 89616 KB Output is correct
28 Correct 211 ms 91244 KB Output is correct
29 Correct 666 ms 95368 KB Output is correct
30 Correct 467 ms 92344 KB Output is correct
31 Correct 474 ms 92484 KB Output is correct
32 Correct 521 ms 95296 KB Output is correct
33 Correct 44 ms 82448 KB Output is correct
34 Correct 50 ms 82404 KB Output is correct
35 Correct 47 ms 82428 KB Output is correct
36 Correct 53 ms 82472 KB Output is correct
37 Correct 47 ms 82424 KB Output is correct
38 Correct 54 ms 82436 KB Output is correct
39 Correct 46 ms 82492 KB Output is correct
40 Correct 51 ms 82376 KB Output is correct
41 Correct 46 ms 82388 KB Output is correct
42 Correct 55 ms 82372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 82472 KB Output is correct
2 Incorrect 100 ms 84676 KB Output isn't correct
3 Halted 0 ms 0 KB -