답안 #790405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790405 2023-07-22T15:46:25 Z 1075508020060209tc Friends (BOI17_friends) C++14
0 / 100
0 ms 300 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

int n;int p;int q;
vector<int>e[20];
vector<int>gps[20];
int odgr[20];
int gpid[20];
void chk(){
for(int i=1;i<=n;i++){
    odgr[i]=0;
}
for(int i=1;i<=n;i++){
    for(int j=0;j<e[i].size();j++){
        int v=e[i][j];
        if(gpid[v]!=gpid[i]){
            odgr[gpid[i]]++;
            if(odgr[gpid[i]]>q){return;}
        }
    }
}
cout<<"home\n";
int cnt=0;
for(int i=1;i<=n+1;i++){
    if(gps[i].size()==0){
        cnt=i-1;break;
    }
}
cout<<cnt<<endl;
for(int i=1;i<=cnt;i++){
    cout<<gps[i].size()<<" ";
    for(int j=0;j<gps[i].size();j++){
        cout<<gps[i][j]-1<<" ";
    }cout<<endl;
}
exit(0);
}


void dfs(int nw){
if(nw==n+1){
    chk();
    return;
}
for(int i=1;i<=n;i++){
    if(gps[i].size()==p){continue;}
    gps[i].push_back(nw);
    gpid[nw]=i;
    dfs(nw+1);
    gps[i].pop_back();
    if(gps[i].size()==0){break;}
}

}


signed main()
{
    cin>>n>>p>>q;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            v++;
            e[i].push_back(v);
        }
    }
    dfs(1);
    cout<<"detention\n";

}

Compilation message

friends.cpp: In function 'void chk()':
friends.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int j=0;j<e[i].size();j++){
      |                 ~^~~~~~~~~~~~
friends.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int j=0;j<gps[i].size();j++){
      |                 ~^~~~~~~~~~~~~~
friends.cpp: In function 'void dfs(int)':
friends.cpp:48:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     if(gps[i].size()==p){continue;}
      |        ~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 212 KB EMERGENCY!!! contestant found solution when jury didn't
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 300 KB EMERGENCY!!! contestant found solution when jury didn't
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 300 KB EMERGENCY!!! contestant found solution when jury didn't
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 212 KB EMERGENCY!!! contestant found solution when jury didn't
2 Halted 0 ms 0 KB -