Submission #68456

# Submission time Handle Problem Language Result Execution time Memory
68456 2018-08-17T07:27:17 Z yusufake Bank (IZhO14_bank) C++
0 / 100
15 ms 920 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3;

#define pb push_back
vector < int > V[N];
bool H[20][1<<20];
int A[N],B[N],T[N],n,m,i,j,t,ans;

void f(int i, int m){
    if(ans) return;
    if(i == n) { ans = 1; return; }
    if(H[i][m]) return;
    H[i][m] = 1;
    int j, x = A[i];
    for(j=0;j<V[x].size();j++){
        if((V[x][j] & m) == V[x][j])
            f(i+1,(m^V[x][j]));
    }                   
}                       
                        
int main(){
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++) { scanf("%d",&A[i]); T[ A[i] ] = 1; }
    for(i=0;i<m;i++) scanf("%d",&B[i]);
                        
    for(i=1;i<(1<<m);i++){
        t = 0;          
        for(j=0;j<m;j++)    
            if(i & (1 << j))    
                t += B[j];          
        if(!T[t]) continue;             
        V[t].pb(i);                         
    }                                           
                                                        
    ans = 0;                                                        
    f(0,(1<<m)-1);                                                      
    puts(ans ? "YES" : "NO");                                           
    return 0;     
}                   

Compilation message

bank.cpp: In function 'void f(int, int)':
bank.cpp:17:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(j=0;j<V[x].size();j++){
             ~^~~~~~~~~~~~
bank.cpp: In function 'int main()':
bank.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
bank.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<n;i++) { scanf("%d",&A[i]); T[ A[i] ] = 1; }
                        ~~~~~^~~~~~~~~~~~
bank.cpp:26:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<m;i++) scanf("%d",&B[i]);
                      ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 4 ms 456 KB Output is correct
5 Runtime error 15 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 2 ms 920 KB Output is correct
4 Correct 2 ms 920 KB Output is correct
5 Correct 2 ms 920 KB Output is correct
6 Correct 2 ms 920 KB Output is correct
7 Correct 2 ms 920 KB Output is correct
8 Correct 2 ms 920 KB Output is correct
9 Correct 2 ms 920 KB Output is correct
10 Runtime error 2 ms 920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 4 ms 456 KB Output is correct
5 Runtime error 15 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -