# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1026545 | 2024-07-18T07:53:06 Z | hasan2006 | Paths (BOI18_paths) | C++17 | 344 ms | 120972 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 3e5 + 9 , mod = 1e9 + 7; ll a[N] , b[N] , dp[N][40] , c[N] , d[N] ; vector<int>v[N]; void solve() { ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ; cin>>n>>m>>k; for(i = 1; i <= n; i++){ cin>>a[i]; a[i]--; dp[i][1<<a[i]] = 1; } for(i = 1; i <= m; i++){ cin>>l>>r; v[l].pb(r); v[r].pb(l); } for(j = 1; j < 32; j++) for(i =n ; i > 0; i--) for(auto to : v[i]) if(j & (1 << a[i])) dp[i][j] += dp[to][j- (1 << a[i])] , s += dp[to][j- (1 << a[i])]; cout<<s<<"\n"; } int main(){ TL; /*#ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int t = 1; // cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 12888 KB | Output is correct |
2 | Correct | 2 ms | 12888 KB | Output is correct |
3 | Correct | 2 ms | 12892 KB | Output is correct |
4 | Correct | 2 ms | 12892 KB | Output is correct |
5 | Correct | 2 ms | 12888 KB | Output is correct |
6 | Correct | 2 ms | 12892 KB | Output is correct |
7 | Correct | 2 ms | 12952 KB | Output is correct |
8 | Correct | 2 ms | 12916 KB | Output is correct |
9 | Correct | 2 ms | 12892 KB | Output is correct |
10 | Correct | 2 ms | 12892 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 18524 KB | Output is correct |
2 | Correct | 45 ms | 16472 KB | Output is correct |
3 | Correct | 336 ms | 119892 KB | Output is correct |
4 | Correct | 85 ms | 30916 KB | Output is correct |
5 | Correct | 83 ms | 30984 KB | Output is correct |
6 | Correct | 198 ms | 88264 KB | Output is correct |
7 | Correct | 324 ms | 120200 KB | Output is correct |
8 | Correct | 332 ms | 120972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 12888 KB | Output is correct |
2 | Correct | 2 ms | 12888 KB | Output is correct |
3 | Correct | 2 ms | 12892 KB | Output is correct |
4 | Correct | 2 ms | 12892 KB | Output is correct |
5 | Correct | 2 ms | 12888 KB | Output is correct |
6 | Correct | 2 ms | 12892 KB | Output is correct |
7 | Correct | 2 ms | 12952 KB | Output is correct |
8 | Correct | 2 ms | 12916 KB | Output is correct |
9 | Correct | 2 ms | 12892 KB | Output is correct |
10 | Correct | 2 ms | 12892 KB | Output is correct |
11 | Correct | 56 ms | 18524 KB | Output is correct |
12 | Correct | 45 ms | 16472 KB | Output is correct |
13 | Correct | 336 ms | 119892 KB | Output is correct |
14 | Correct | 85 ms | 30916 KB | Output is correct |
15 | Correct | 83 ms | 30984 KB | Output is correct |
16 | Correct | 198 ms | 88264 KB | Output is correct |
17 | Correct | 324 ms | 120200 KB | Output is correct |
18 | Correct | 332 ms | 120972 KB | Output is correct |
19 | Correct | 63 ms | 21264 KB | Output is correct |
20 | Correct | 43 ms | 18772 KB | Output is correct |
21 | Correct | 326 ms | 120400 KB | Output is correct |
22 | Correct | 84 ms | 30804 KB | Output is correct |
23 | Correct | 107 ms | 30900 KB | Output is correct |
24 | Correct | 204 ms | 88328 KB | Output is correct |
25 | Correct | 326 ms | 120400 KB | Output is correct |
26 | Correct | 328 ms | 120916 KB | Output is correct |
27 | Correct | 43 ms | 18768 KB | Output is correct |
28 | Correct | 64 ms | 22100 KB | Output is correct |
29 | Correct | 344 ms | 120312 KB | Output is correct |
30 | Correct | 164 ms | 70092 KB | Output is correct |
31 | Correct | 181 ms | 70088 KB | Output is correct |
32 | Correct | 329 ms | 120400 KB | Output is correct |
33 | Correct | 2 ms | 12892 KB | Output is correct |
34 | Correct | 2 ms | 12892 KB | Output is correct |
35 | Correct | 2 ms | 12892 KB | Output is correct |
36 | Correct | 2 ms | 12944 KB | Output is correct |
37 | Correct | 2 ms | 12892 KB | Output is correct |
38 | Correct | 2 ms | 12892 KB | Output is correct |
39 | Correct | 2 ms | 12892 KB | Output is correct |
40 | Correct | 2 ms | 12892 KB | Output is correct |
41 | Correct | 2 ms | 12892 KB | Output is correct |
42 | Correct | 2 ms | 12888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 12892 KB | Output is correct |
2 | Correct | 16 ms | 14080 KB | Output is correct |
3 | Correct | 15 ms | 13916 KB | Output is correct |
4 | Correct | 76 ms | 46500 KB | Output is correct |
5 | Correct | 51 ms | 47048 KB | Output is correct |
6 | Correct | 67 ms | 46500 KB | Output is correct |
7 | Correct | 16 ms | 14076 KB | Output is correct |
8 | Correct | 62 ms | 46504 KB | Output is correct |
9 | Correct | 46 ms | 47048 KB | Output is correct |
10 | Correct | 53 ms | 47320 KB | Output is correct |
11 | Correct | 41 ms | 31192 KB | Output is correct |
12 | Correct | 51 ms | 40268 KB | Output is correct |
13 | Correct | 40 ms | 31324 KB | Output is correct |
14 | Correct | 63 ms | 46424 KB | Output is correct |
15 | Correct | 62 ms | 46428 KB | Output is correct |
16 | Correct | 2 ms | 12892 KB | Output is correct |
17 | Correct | 2 ms | 12892 KB | Output is correct |
18 | Correct | 2 ms | 12892 KB | Output is correct |
19 | Correct | 3 ms | 12892 KB | Output is correct |
20 | Correct | 2 ms | 12892 KB | Output is correct |
21 | Correct | 2 ms | 12892 KB | Output is correct |
22 | Correct | 2 ms | 12892 KB | Output is correct |
23 | Correct | 2 ms | 12892 KB | Output is correct |
24 | Correct | 2 ms | 12892 KB | Output is correct |
25 | Correct | 2 ms | 12892 KB | Output is correct |