Submission #418098

# Submission time Handle Problem Language Result Execution time Memory
418098 2021-06-05T05:54:57 Z juggernaut Paths (BOI18_paths) C++17
23 / 100
3000 ms 13756 KB
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
typedef long long ll;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef IOI2021SG
    #define printl(args...)printf(args)
#else
    #define printl(args...)((void)0)
#endif
int n,m,k;
int a[300005];
vector<int>g[300005];
ll ans;
bool vis[300005],used[6];
void dfs(int v){
    ans++;
    vis[v]=true;
    used[a[v]]=true;
    for(int to:g[v])if(!vis[to]&&!used[a[to]])dfs(to);
    vis[v]=false;
    used[a[v]]=false;
}
int main(){
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    while(m--){
        int x,y;
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=1;i<=n;i++)dfs(i);
    printf("%d",ans-n);
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:43:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
   43 |     printf("%d",ans-n);
      |             ~^  ~~~~~
      |              |     |
      |              int   ll {aka long long int}
      |             %lld
paths.cpp: In function 'void usaco(std::string)':
paths.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp: In function 'int main()':
paths.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     scanf("%d%d%d",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
paths.cpp:35:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     for(int i=1;i<=n;i++)scanf("%d",&a[i]);
      |                          ~~~~~^~~~~~~~~~~~
paths.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7244 KB Output is correct
2 Correct 4 ms 7244 KB Output is correct
3 Correct 4 ms 7244 KB Output is correct
4 Correct 4 ms 7244 KB Output is correct
5 Correct 4 ms 7356 KB Output is correct
6 Correct 4 ms 7244 KB Output is correct
7 Correct 5 ms 7244 KB Output is correct
8 Correct 4 ms 7244 KB Output is correct
9 Correct 5 ms 7356 KB Output is correct
10 Correct 4 ms 7244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 13756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7244 KB Output is correct
2 Correct 4 ms 7244 KB Output is correct
3 Correct 4 ms 7244 KB Output is correct
4 Correct 4 ms 7244 KB Output is correct
5 Correct 4 ms 7356 KB Output is correct
6 Correct 4 ms 7244 KB Output is correct
7 Correct 5 ms 7244 KB Output is correct
8 Correct 4 ms 7244 KB Output is correct
9 Correct 5 ms 7356 KB Output is correct
10 Correct 4 ms 7244 KB Output is correct
11 Execution timed out 3041 ms 13756 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7244 KB Output is correct
2 Execution timed out 3073 ms 9160 KB Time limit exceeded
3 Halted 0 ms 0 KB -