제출 #91100

#제출 시각아이디문제언어결과실행 시간메모리
91100Aydarov03은행 (IZhO14_bank)C++14
71 / 100
85 ms7964 KiB
#include <stdio.h> #include <stdlib.h> #include <vector> #include <algorithm> using namespace std; int a[25] , b[25]; vector <int> v[20005]; int n , m; void rec( int id = 1 , int OR = 0) { for(auto c : v[ a[id] ] ) { if( (c & OR) == 0 ) { if( id == n ) { puts("YES"); exit(0); } rec( id+1 , OR | c ); } } } main() { scanf("%d%d" , &n , &m); for(int i = 1; i <= n; i++) scanf("%d" , &a[i]); for(int i = 1; i <= m; i++) scanf("%d" , &b[i]); if( n == m ) { sort( a + 1 , a + n + 1 ); sort( b + 1 , b + n + 1 ); for(int i = 1; i <= n; i++) if( a[i] != b[i] ) { puts("NO"); return 0; } puts("YES"); } for(int mask = 1; mask < (1<<m); mask++) { int sum = 0; for(int i = 0; i < m; i++) { if( mask & ( (1<<i) ) ) sum += b[i+1]; } v[sum].push_back( mask ); } for(int i = 1; i <= n; i++) { if( v[a[i]].size() == 0 ) { puts("NO"); return 0; } } rec(); puts("NO"); }

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

bank.cpp:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
bank.cpp: In function 'int main()':
bank.cpp:45:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(int i = 1; i <= n; i++)
         ^~~
bank.cpp:52:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             puts("YES");
             ^~~~
bank.cpp:34: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:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d" , &a[i]);
         ~~~~~^~~~~~~~~~~~~~
bank.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d" , &b[i]);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...