# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
153123 |
2019-09-12T14:10:09 Z |
Swan |
Paths (BOI18_paths) |
C++14 |
|
3000 ms |
10464 KB |
#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("solve1.txt","w",stdout)
#define int long long
using namespace std;
typedef long long ll;
vector<vector<int> > v;
const int maxn = 4e5;
int color[maxn];
bool c_used[maxn];
bool used[maxn];
bool is_good(int mask,int x){
return !(mask&(1<<x));
}
int ans = 0 ;
void dfs(int u,int mask){
if(mask)ans++;
mask|=(1<<color[u]);
for(int i(0); i < v[u].size();i++){
int to = v[u][i];
if(!is_good(mask,color[to]))continue;
dfs(to,mask);
}
}
main()
{
ios_base::sync_with_stdio(0);
int n,m,k; cin >> n >> m >> k;
v.resize(n+2);
for(int i(0); i < n;i++)cin >> color[i];
for(int i(0); i < m;i++){
int a,b; cin >> a >> b;
a--;b--;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i(0); i < n;i++){
dfs(i,0);
}
cout << ans;
return 0;
}
/*
*/
Compilation message
paths.cpp: In function 'void dfs(long long int, long long int)':
paths.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i(0); i < v[u].size();i++){
~~^~~~~~~~~~~~~
paths.cpp: At global scope:
paths.cpp:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3089 ms |
10464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Execution timed out |
3089 ms |
10464 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Execution timed out |
3092 ms |
3164 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |