답안 #106356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106356 2019-04-18T02:57:31 Z abil Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1000 ms 504 KB
#include <bits/stdc++.h>
#define int long long
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)
#define pi pair < int, int >

using namespace std;

const long long INF = (int)1e18 + 7;
const int N = (int)2007;
const int mod = 1000000007;

int n, a, b, ans = INF, arr[N];
void dfs(int g,int pos,int sum,int an){
      if(pos - 1 == n){
            if(g == 0){
                   ans = min(ans,(an | sum));
            }
      }
      else{
                  if(g == 0){
                        dfs(g, pos + 1, sum + arr[pos], an);
                  }
                  else{
                        dfs(g,pos + 1, sum + arr[pos], an);
                        dfs(g - 1,pos + 1, arr[pos], (an | sum));
                  }
      }
}
main(){
      cin >> n >> a >> b;
      for(int i = 1;i <= n; i++){
            Scan(arr[i]);
      }
      for(int i = a;i <= b; i++){
            dfs(i - 1,1,0,0);
      }
      cout << ans;

}
/*
6 1 3
8 1 2 1 5 4
*/

Compilation message

sculpture.cpp:36:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:9:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 #define Scan(a) scanf ("%I64d", &a)
                                 ~~^~
 #define scan(a) scanf ("%d", &a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 #define pi pair < int, int >
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      
 
 ~                                  
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~              
 
 ~                                  
 const long long INF = (int)1e18 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 const int N = (int)2007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~          
 const int mod = 1000000007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 
 ~                                  
 int n, a, b, ans = INF, arr[N];
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
 void dfs(int g,int pos,int sum,int an){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(pos - 1 == n){
       ~~~~~~~~~~~~~~~~~~           
             if(g == 0){
             ~~~~~~~~~~~~           
                    ans = min(ans,(an | sum));
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
             }
             ~~                     
       }
       ~~                           
       else{
       ~~~~~~                       
                   if(g == 0){
                   ~~~~~~~~~~~~     
                         dfs(g, pos + 1, sum + arr[pos], an);
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   }
                   ~~               
                   else{
                   ~~~~~~           
                         dfs(g,pos + 1, sum + arr[pos], an);
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         dfs(g - 1,pos + 1, arr[pos], (an | sum));
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   }
                   ~~               
       }
       ~~                           
 }
 ~~                                 
 main(){
 ~~~~~~~~                           
       cin >> n >> a >> b;
       ~~~~~~~~~~~~~~~~~~~~         
       for(int i = 1;i <= n; i++){
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
             Scan(arr[i]);
             ~~~~~~~~~~~            
sculpture.cpp:39:13: note: in expansion of macro 'Scan'
             Scan(arr[i]);
             ^~~~
sculpture.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define Scan(a) scanf ("%I64d", &a)
                 ~~~~~~^~~~~~~~~~~~~
sculpture.cpp:39:13: note: in expansion of macro 'Scan'
             Scan(arr[i]);
             ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 52 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Incorrect 2 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 356 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 40 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Incorrect 2 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 304 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 300 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 37 ms 384 KB Output is correct
14 Correct 122 ms 384 KB Output is correct
15 Correct 45 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Execution timed out 1077 ms 256 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 61 ms 376 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Incorrect 2 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 65 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 19 ms 284 KB Output is correct
21 Correct 57 ms 256 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 75 ms 384 KB Output is correct
24 Correct 131 ms 504 KB Output is correct
25 Correct 41 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Execution timed out 1058 ms 384 KB Time limit exceeded
28 Halted 0 ms 0 KB -