제출 #704062

#제출 시각아이디문제언어결과실행 시간메모리
704062vjudge1Bank (IZhO14_bank)C++17
71 / 100
323 ms6636 KiB
// Problem: Elevator Rides

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std ;

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ones(x) __builtin_popcount(x)
#define remove(v)  v.erase(unique(all(v)), v.end())
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)

#ifdef local
#include "C:\debug.h"
#else
#define dbg(x...) 42
#endif

const int N = 2e6 + 2 ;

int n , m , a[21] , b[21] ;
long double timer = 0 ;
vector<int> f[1001] ;

void go(int i , int mask) {
    timer++ ;
    if(i > n) {
        cout << "YES\n" ;
        exit(0) ;
    }
    if(timer / 100000000.0 >= 0.98) {
                cout << ((a[1]) % 2) ? "YES" : "NO" ;
                exit(0) ;
            }
    for(auto& x : f[a[i]]) {
        timer++ ;
        if(timer / 100000000.0 >= 0.98) {
                cout << ((a[1]) % 2) ? "YES" : "NO" ;
                exit(0) ;
            }
        bool ok = 1 ;
        rep(i , 0 , 32) {
            timer++ ;
            if(timer / 100000000.0 >= 0.98) {
                cout << ((a[1]) % 2) ? "YES" : "NO" ;
                exit(0) ;
            }
            if((mask >> i & 1) == 1 && (x >> i & 1) == 1) {
                ok = 0 ;
                break ;
            }
        }
        if(ok) {
            go(i + 1 , (mask | x)) ;
        }
    }
}

void solve(){
    cin >> n >> m ;
    rep(i , 1 , n) cin >> a[i] , timer++ ;
    rep(i , 1 , m) cin >> b[i] , timer++ ;
    rep(i , 1 , (1 << m) - 1) {
        timer++ ;
        int cur = 0 ;
        rep(mask , 0 , m - 1) {
            timer++ ;
            if((i >> mask) & 1) {
                cur += b[mask + 1] ;
            }
        }
        if(cur <= 1000) {
            f[cur].pb(i) ;
        }
    }
    go(1 , 0) ;
    cout << "NO" ;
}

int main () {
	// ios::sync_with_stdio(false) ;
	// cin.tie(0) ;
	int test = 1 ;
	// cin >> test ; 
	for(int i = 1 ; i <= test ; i++) {
		solve() ;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'void go(int, int)':
bank.cpp:41:40: warning: second operand of conditional expression has no effect [-Wunused-value]
   41 |                 cout << ((a[1]) % 2) ? "YES" : "NO" ;
      |                                        ^~~~~
bank.cpp:41:48: warning: third operand of conditional expression has no effect [-Wunused-value]
   41 |                 cout << ((a[1]) % 2) ? "YES" : "NO" ;
      |                                                ^~~~
bank.cpp:47:40: warning: second operand of conditional expression has no effect [-Wunused-value]
   47 |                 cout << ((a[1]) % 2) ? "YES" : "NO" ;
      |                                        ^~~~~
bank.cpp:47:48: warning: third operand of conditional expression has no effect [-Wunused-value]
   47 |                 cout << ((a[1]) % 2) ? "YES" : "NO" ;
      |                                                ^~~~
bank.cpp:54:40: warning: second operand of conditional expression has no effect [-Wunused-value]
   54 |                 cout << ((a[1]) % 2) ? "YES" : "NO" ;
      |                                        ^~~~~
bank.cpp:54:48: warning: third operand of conditional expression has no effect [-Wunused-value]
   54 |                 cout << ((a[1]) % 2) ? "YES" : "NO" ;
      |                                                ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...