# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
63190 | 2018-08-01T05:14:20 Z | 정원준(#1835) | Paths (BOI18_paths) | C++11 | 3000 ms | 95712 KB |
#include <bits/stdc++.h> #define L long long using namespace std; L n,m,k,ans; L dp[300030][32]; L col[300030]; vector<L>bit[6]; vector<L>v[300030]; L bits(L x){ L ret=0; while(x) { ret+=x%2; x/=2; } return ret; } int main() { scanf("%lld %lld %lld",&n,&m,&k); L i,bi,binum,j,k; for(i=1;i<32;i++) { bit[bits(i)].push_back(i); } for(i=1;i<=n;i++) { scanf("%lld",&col[i]); col[i]--; } for(i=1;i<=m;i++) { L s,e; scanf("%lld %lld",&s,&e); v[s].push_back(e); v[e].push_back(s); } for(i=1;i<=n;i++) { dp[i][(1<<col[i])]=1; ans--; } for(i=1;i<=5;i++) { //printf("%lld\n",i); for(binum=0;binum<bit[i].size();binum++) { bi=bit[i][binum]; //printf("%lld ",bi); for(j=1;j<=n;j++) { ans+=dp[j][bi]; for(k=0;k<v[j].size();k++) { if(!(bi&(1<<col[v[j][k]]))) { dp[v[j][k]][bi|(1<<col[v[j][k]])]+=dp[j][bi]; } } } } //puts(""); } /*for(i=0;i<32;i++) { for(j=1;j<=n;j++) { printf("%lld ",dp[j][i]); } puts(""); }*/ printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 7416 KB | Output is correct |
2 | Correct | 9 ms | 7524 KB | Output is correct |
3 | Correct | 8 ms | 7524 KB | Output is correct |
4 | Correct | 9 ms | 7668 KB | Output is correct |
5 | Correct | 9 ms | 7668 KB | Output is correct |
6 | Correct | 9 ms | 7668 KB | Output is correct |
7 | Correct | 10 ms | 7744 KB | Output is correct |
8 | Correct | 10 ms | 7744 KB | Output is correct |
9 | Correct | 9 ms | 7744 KB | Output is correct |
10 | Correct | 9 ms | 7744 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 299 ms | 16132 KB | Output is correct |
2 | Correct | 227 ms | 16132 KB | Output is correct |
3 | Execution timed out | 3045 ms | 95712 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 7416 KB | Output is correct |
2 | Correct | 9 ms | 7524 KB | Output is correct |
3 | Correct | 8 ms | 7524 KB | Output is correct |
4 | Correct | 9 ms | 7668 KB | Output is correct |
5 | Correct | 9 ms | 7668 KB | Output is correct |
6 | Correct | 9 ms | 7668 KB | Output is correct |
7 | Correct | 10 ms | 7744 KB | Output is correct |
8 | Correct | 10 ms | 7744 KB | Output is correct |
9 | Correct | 9 ms | 7744 KB | Output is correct |
10 | Correct | 9 ms | 7744 KB | Output is correct |
11 | Correct | 299 ms | 16132 KB | Output is correct |
12 | Correct | 227 ms | 16132 KB | Output is correct |
13 | Execution timed out | 3045 ms | 95712 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 95712 KB | Output is correct |
2 | Correct | 70 ms | 95712 KB | Output is correct |
3 | Correct | 87 ms | 95712 KB | Output is correct |
4 | Correct | 757 ms | 95712 KB | Output is correct |
5 | Correct | 283 ms | 95712 KB | Output is correct |
6 | Correct | 520 ms | 95712 KB | Output is correct |
7 | Correct | 76 ms | 95712 KB | Output is correct |
8 | Correct | 671 ms | 95712 KB | Output is correct |
9 | Correct | 289 ms | 95712 KB | Output is correct |
10 | Correct | 506 ms | 95712 KB | Output is correct |
11 | Correct | 316 ms | 95712 KB | Output is correct |
12 | Correct | 291 ms | 95712 KB | Output is correct |
13 | Correct | 289 ms | 95712 KB | Output is correct |
14 | Correct | 527 ms | 95712 KB | Output is correct |
15 | Correct | 605 ms | 95712 KB | Output is correct |
16 | Correct | 10 ms | 95712 KB | Output is correct |
17 | Correct | 10 ms | 95712 KB | Output is correct |
18 | Correct | 9 ms | 95712 KB | Output is correct |
19 | Correct | 10 ms | 95712 KB | Output is correct |
20 | Correct | 9 ms | 95712 KB | Output is correct |
21 | Correct | 10 ms | 95712 KB | Output is correct |
22 | Correct | 8 ms | 95712 KB | Output is correct |
23 | Correct | 9 ms | 95712 KB | Output is correct |
24 | Correct | 10 ms | 95712 KB | Output is correct |
25 | Correct | 11 ms | 95712 KB | Output is correct |