Submission #1075759

# Submission time Handle Problem Language Result Execution time Memory
1075759 2024-08-26T09:03:07 Z edogawa_something Simurgh (IOI17_simurgh) C++17
0 / 100
8 ms 12376 KB
#include "simurgh.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
const ll M=250000;
vector<pii> adj[M];
bool vis[M];
vii sp;
void dfs(ll x) {
  vis[x]=1;
  for(auto it:adj[x]) {
    if(vis[it.F])
      continue;
    else {
      sp.pb(it.S);
      dfs(it.F);
    }
  }
}
struct dsu {
  ll sz[250],pa[250];
  void init(ll x) {
    for(int i=0;i<x;i++)
      sz[i]=1,pa[i]=i;
  }
  ll get(ll x) {
    if(x==pa[x])
      return x;
    return pa[x]=get(pa[x]);
  }
  void unite(ll x,ll y) {
    x=get(x),y=get(y);
    if(x==y)
      return;
    if(sz[x]>sz[y])
      swap(x,y);
    pa[x]=y;
    sz[y]+=sz[x];
  }
}d;
ll cnt[M],cc[M];
set<ll>s;
vector<int> find_roads(int n, std::vector<int> u, std::vector<int> vv) {
  for(int i=0;i<u.size();i++)
    adj[u[i]].pb({vv[i],i}),adj[vv[i]].pb({u[i],i});
  dfs(0);
  vector<int>ans,res;
  for(int i=0;i<u.size();i++)
    vis[i]=0;
  ll cc=0;
  for(auto it:sp) {
    s.clear();
    ans.clear();
    d.init(n);
    vii vv;
    for(auto itt:sp) {
      if(itt!=it)
        ans.pb(itt);
    }
    for(int i=0;i<u.size();i++)
      cnt[i]=0;
    for(int i=0;i<u.size();i++) {
      if(!vis[i]) {
        ans.pb(i);
        ll x=count_common_roads(ans);
        cc++;
        cnt[ans.back()]=x;
        s.insert(x);
        vv.pb(i);
        vis[i]=1;
        ans.pop_back();
      }
    }
    for(auto it:vv) {
      if(cnt[it]!=*s.begin()) {
        res.pb(it);
      }
    }
  }
  assert(res.size()==n-1);
  assert(cc<=30000);
  return res;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:50:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for(int i=0;i<u.size();i++)
      |               ~^~~~~~~~~
simurgh.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int i=0;i<u.size();i++)
      |               ~^~~~~~~~~
simurgh.cpp:66:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for(int i=0;i<u.size();i++)
      |                 ~^~~~~~~~~
simurgh.cpp:68:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for(int i=0;i<u.size();i++) {
      |                 ~^~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from simurgh.cpp:2:
simurgh.cpp:86:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   86 |   assert(res.size()==n-1);
      |          ~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6236 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6236 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6236 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 12376 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6236 KB WA in grader: NO
2 Halted 0 ms 0 KB -