Submission #418100

# Submission time Handle Problem Language Result Execution time Memory
418100 2021-06-05T05:59:38 Z juggernaut Paths (BOI18_paths) C++17
0 / 100
269 ms 21548 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;
int cnt[6];
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);
    }
    if(k==1)puts("0");
    else if(k==2){
        for(int i=1;i<=n;i++)for(int to:g[i])if(a[to]!=a[i])ans++;
        printf("%d",ans);
    }else if(k==3){
        for(int i=1;i<=n;i++)for(int to:g[i])if(a[to]!=a[i])ans++;
        for(int i=1;i<=n;i++){
            cnt[1]=cnt[2]=cnt[3]=0;
            int all=0;
            for(int to:g[i])if(a[to]!=a[i])cnt[a[to]]++,all++;
            for(int to:g[i])if(a[to]!=a[i])ans+=all-cnt[a[to]];
        }
        printf("%d",ans);
    }
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:37:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
   37 |         printf("%d",ans);
      |                 ~^  ~~~
      |                  |  |
      |                  |  ll {aka long long int}
      |                  int
      |                 %lld
paths.cpp:46:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
   46 |         printf("%d",ans);
      |                 ~^  ~~~
      |                  |  |
      |                  |  ll {aka long long int}
      |                  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:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d%d%d",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
paths.cpp:27:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     for(int i=1;i<=n;i++)scanf("%d",&a[i]);
      |                          ~~~~~^~~~~~~~~~~~
paths.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 88 ms 10884 KB Output is correct
2 Correct 77 ms 13104 KB Output is correct
3 Correct 269 ms 21548 KB Output is correct
4 Correct 112 ms 15120 KB Output is correct
5 Correct 106 ms 15100 KB Output is correct
6 Incorrect 198 ms 19380 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7244 KB Output isn't correct
2 Halted 0 ms 0 KB -