답안 #280489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
280489 2020-08-22T20:21:44 Z ajpiano 친구 (IOI14_friend) C++14
11 / 100
39 ms 2816 KB
#include <bits/stdc++.h>
#include <friend.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int findSample(int n, int conf[], int host[], int pr[]){
    assert(n <= 20);
    vi edges[n];
    F0R(i,1,n-1){
        int h = host[i];
        if(pr[i] == 0){
            edges[h].push_back(i);
            edges[i].push_back(h);
        }else{
            for(auto &a: edges[h]){
                edges[i].push_back(a);
                edges[a].push_back(i);
            }
            if(pr[i] == 2){
                edges[i].push_back(h);
                edges[h].push_back(i);
            }
        }
    }
    int best = 0;
    FOR(mask,(1<<n)){
        int cur = 0;
        bool good = 1;
        vector<bool> found(n);
        FOR(i,n){
            if((1<<i)&mask){
                cur += conf[i];
                found[i] = 1;
            }
        }
        if(cur <= best) continue;
        FOR(i,n){
            if(!found[i]) continue;
            for(auto &a: edges[i]){
                assert(a != i);
                if(found[a]){
                    good = 0;
                    break;
                }
            }
            if(!good) break;
        }
        if(good) best = cur;
    }
    assert(best != 0);
    return best;
}

//void grader(){
//    int n; cin >> n;
//    int conf[n],host[n],pr[n];
//    FOR(i,n) cin >> conf[i];
//    F0R(i,1,n-1) cin >> host[i] >> pr[i];
//    cout << "Answer: " << findSample(n,conf,host,pr);
//}
//
//int main()
//{
//    ios_base::sync_with_stdio(0); cin.tie(0);
//    grader();
//    return 0;
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 276 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Runtime error 1 ms 512 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Runtime error 1 ms 512 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Runtime error 39 ms 2816 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -