Submission #601727

#TimeUsernameProblemLanguageResultExecution timeMemory
601727ktkeremPaths (BOI18_paths)C++17
100 / 100
501 ms102744 KiB
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/ #include<bits/stdc++.h> /*#include <bits/extc++.h> using namespace std; using namespace __gnu_pbds; template<class T> using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; /**/ //typedef int ll; typedef long long ll; typedef unsigned long long ull; typedef __int128 vll; typedef unsigned __int128 uvll; ll _i=0; #define ffn(x) _i=x #define llll std::pair<ll , ll> #define stitr set<ll>::iterator #define fora(y,x) for(ll y=_i;x>y;y++) #define pb push_back #define pf push_front #define halo cout << "hello\n" #define fi first #define sec second #define all(a) a.begin() , a.end() const ll limit = 1e9+7; const ll ous = 2e5 + 7; const ll dx[4] = {1 , 0 , 0 , -1} , dy[4] = {0,1,-1,0}; void solve(){ ll n , m , k;std::cin >> n >> m >> k; ll ar[n]; ll dp[n+1][33]; memset(dp , 0 , sizeof(dp)); std::vector<ll> v[k + 2] , adj[n+5]; fora(i , n){ std::cin >> ar[i]; } fora(i , (1 << k)){ ll s = __builtin_popcount(i); v[s].pb(i); } fora(i , n){ dp[i][(1 << (ar[i] - 1))] = 1; } fora(i , m){ ll x , y;std::cin >> x >> y; x--;y--; adj[x].pb(y); adj[y].pb(x); } for(ll o = 2;k>=o;o++){ fora(i , n){ for(auto j:adj[i]){ for(auto vl:v[o - 1]){ if(vl & (1 << (ar[i] - 1))){ continue; } dp[i][vl | (1 << (ar[i] - 1))] += dp[j][vl]; } } } } ll ans = 0; fora(i , n){ for(ll j = 2;k>=j;j++){ for(auto o:v[j]){ ans+=dp[i][o]; } } } std::cout << ans << "\n"; return;/**/ } signed main(){ std::ios_base::sync_with_stdio(false);std::cin.tie(NULL); ll t=1; // std::cin >> t; ll o = 1; while(t--){ //cout << "Case " << o++ << ":\n"; solve(); } return 0; }

Compilation message (stderr)

paths.cpp:12:1: warning: "/*" within comment [-Wcomment]
   12 | /**/
      |  
paths.cpp: In function 'int main()':
paths.cpp:81:8: warning: unused variable 'o' [-Wunused-variable]
   81 |     ll o = 1;
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...