Submission #940082

# Submission time Handle Problem Language Result Execution time Memory
940082 2024-03-07T05:20:12 Z Wansur Simurgh (IOI17_simurgh) C++14
0 / 100
27 ms 70736 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'

std::vector<int> ask(int i);
typedef long long ll;
using namespace std;

int count_common_roads(const std::vector<int>& r);

struct seg{
    int m1,m2,sum,cnt;
};
const string out[2]={"NO\n","YES\n"};
const ll dx[]={0,1,0,-1,-1,1,1,-1};
const ll dy[]={1,0,-1,0,-1,1,-1,1};
const int mod=998244353;
const int md=1e9+7;
const int mx=501;
const bool T=0;

int pos[mx][mx];
bool bad[mx];
int V[mx*mx];
int U[mx*mx];
int N;

int ask(vector<pair<int,int>> v){
    vector<int> r;
    for(auto [x, y]:v){
        r.push_back(pos[x][y]);
    }
    return count_common_roads(r);
}

struct dsu{
    int p[mx];
    vector<pair<int,int>> edge;
    dsu(){
        for(int i=0;i<N;i++){
            p[i]=i;
        }
        edge.clear();
    }

    int get(int x){
        if(p[x]==x){
            return x;
        }
        return p[x]=get(p[x]);
    }

    void merge(int x,int y){
        if(get(x)==get(y)){
            return;
        }
        edge.push_back({x,y});
        p[get(x)]=get(y);
    }
};

vector<dsu> tree;

vector<pair<int,int>> find(dsu x,int last,int n,int m){
    if(x.edge.size()==n-1){
        tree.push_back(x);
        return {};
    }
    for(int i=last;i<m;i++){
        if(x.get(V[i])!=x.get(U[i]) && !bad[i]){
            dsu nw=x;
            nw.merge(V[i],U[i]);
            auto v=find(nw,i+1,n,m);
            for(auto [v, u]: x.edge){
                if(bad[pos[v][u]]){
                    return {};
                }
            }
            if(v.size()!=0)return v;
        }
    }
    return {};
}

vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){
    int m=v.size();
    N=n;
    for(int i=0;i<m;i++){
        V[i]=v[i];
        U[i]=u[i];
        pos[v[i]][u[i]]=pos[u[i]][v[i]]=i;
    }
    dsu nw;
    auto ans=find(nw, 0, n, m);
    vector<int> musor;
    cout<<"! "<<tree.size()<<ent;
    return musor;
}

Compilation message

simurgh.cpp: In function 'int ask(std::vector<std::pair<int, int> >)':
simurgh.cpp:31:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |     for(auto [x, y]:v){
      |              ^
simurgh.cpp: In function 'std::vector<std::pair<int, int> > find(dsu, int, int, int)':
simurgh.cpp:66:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |     if(x.edge.size()==n-1){
      |        ~~~~~~~~~~~~~^~~~~
simurgh.cpp:75:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   75 |             for(auto [v, u]: x.edge){
      |                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 70736 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 70736 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 70736 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 70736 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -