Submission #753277

# Submission time Handle Problem Language Result Execution time Memory
753277 2023-06-05T00:43:51 Z boyliguanhan Tug of War (BOI15_tug) C++17
18 / 100
25 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
int pos[20][2], s[20];
bool check(int n, int k, int p) {
    if(__builtin_popcount(p)!=n/2) return 0;
    bool used[n/2][2];
    memset(used, 0, sizeof used);
    int x=0,y=0;
    for(int i = 0; i < n; i++) {
        bool b = p&1<<i;
        used[pos[i][b]-1][b]=1;
        if(b)x+=s[i];
        else y+=s[i];
    }
    for(int i = 0; i < n/2; i++)
        if(!used[i][0]||!used[i][1])
            return 0;
    return abs(x-y) <= k;
}
int main() {
    int n, k;
    cin >> n >> k;
    n*=2;
    for(int i = 0; i < n; i++) {
        cin >> pos[i][0] >> pos[i][1] >> s[i];
    }
    for(int j = (1 << n/2)-1; j < 1 << n; j++) {
        if(j==201) {
            cout << "";
        }
        if(check(n,k,j)) cout << "YES\n", exit(0);
    }
    cout << "NO\n";
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 23 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 23 ms 296 KB Output is correct
6 Correct 23 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 6 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 23 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 24 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 24 ms 212 KB Output is correct
22 Correct 22 ms 284 KB Output is correct
23 Correct 24 ms 292 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 25 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 23 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 23 ms 296 KB Output is correct
6 Correct 23 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 6 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 23 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 24 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 24 ms 212 KB Output is correct
22 Correct 22 ms 284 KB Output is correct
23 Correct 24 ms 292 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 25 ms 300 KB Output is correct
26 Runtime error 1 ms 340 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 23 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 23 ms 296 KB Output is correct
6 Correct 23 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 6 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 23 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 24 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 24 ms 212 KB Output is correct
22 Correct 22 ms 284 KB Output is correct
23 Correct 24 ms 292 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 25 ms 300 KB Output is correct
26 Runtime error 1 ms 340 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -