Submission #910886

#TimeUsernameProblemLanguageResultExecution timeMemory
910886Isaac_Q1Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include<vector> using namespace std; vector<int> temp; int res = INT_MAX; int h[100][2]; int check() { int ht[100]={0}; int cnt = 0; int n = temp.size(); for(int i=0; i<n; i++) { ht[h[i][0]] ++; ht[h[i][1]] ++; cnt += 2; if(ht[h[i][0]] == 2) cnt -= 2; else if(ht[h[i][0]] > 2) return 0; if(ht[h[i][1]] == 2) cnt -= 2; else if(ht[h[i][1]] > 2) return 0; } if(cnt == 2) return 1; return 0; } void sub(int a[], int ind, int target, int n) { if(ind >= n) return; if(target < 0) return; if(target == 0) { if(check()){ int k = temp.size(); res = min(res, k); } return; } for(int i = ind; i<n; i++) { temp.push_back(i); target -= a[i]; sub(a,i+1,target,n); target += a[i]; temp.pop_back(); } return; } int main() { int n,k; cin >> n >> k; int l[n-1]; for(int i=0; i<n-1; i++) cin >> h[i][0] >> h[i][1]; for(int i=0; i<n-1; i++) { cin >> l[i]; } int u; int u1,u2; for(int i=0; i<n-2; i++) { for(int j=i+1; j<n-1; j++) { if(l[i] > l[j]) { u = l[i]; l[i] = l[j]; l[j] = u; u1 = h[i][0]; h[i][0] = h[j][0]; h[j][0] = u1; u2 = h[i][1]; h[i][1] = h[j][1]; h[j][1] = u2; } } } sub(l,0,k,n-1); if(res == INT_MAX) cout << "-1"; else cout << res; return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccISkm6S.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUjkZGR.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccUjkZGR.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status