Submission #200871

# Submission time Handle Problem Language Result Execution time Memory
200871 2020-02-08T11:04:50 Z oofsauce Detecting Molecules (IOI16_molecules) C++14
0 / 100
7 ms 632 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

int l;
int u;
vector<int> weights;

vector<vector<bool>> visited;
vector<int> ans;

bool recurse(int idx, int w) {
  if(w <= u && w >= l) return true;
  if(idx >= weights.size()) return false;
  if(visited[idx][w]) return false;

  if(recurse(idx+1, w)) return true;
  if(recurse(idx+1, w+weights[idx])) {
    ans.push_back(idx);
    return true;
  }
  visited[idx][w] = true;
  return false;
}

vector<int> find_subset(int l_, int u_, vector<int> weights_) {
  l = l_;
  u = u_;
  weights = weights_;

  visited.resize(weights.size(), vector<bool>(l,false));

  recurse(0,0);

  return ans;
}

Compilation message

molecules.cpp: In function 'bool recurse(int, int)':
molecules.cpp:15:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(idx >= weights.size()) return false;
      ~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 376 KB OK (n = 2, answer = YES)
6 Correct 5 ms 376 KB OK (n = 3, answer = YES)
7 Correct 5 ms 256 KB OK (n = 3, answer = YES)
8 Correct 5 ms 376 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 5 ms 376 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 5 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB OK (n = 12, answer = YES)
2 Correct 5 ms 256 KB OK (n = 12, answer = YES)
3 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 376 KB OK (n = 2, answer = YES)
6 Correct 5 ms 376 KB OK (n = 3, answer = YES)
7 Correct 5 ms 256 KB OK (n = 3, answer = YES)
8 Correct 5 ms 376 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 5 ms 376 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 5 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 376 KB OK (n = 2, answer = YES)
6 Correct 5 ms 376 KB OK (n = 3, answer = YES)
7 Correct 5 ms 256 KB OK (n = 3, answer = YES)
8 Correct 5 ms 376 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 5 ms 376 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 5 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 376 KB OK (n = 2, answer = YES)
6 Correct 5 ms 376 KB OK (n = 3, answer = YES)
7 Correct 5 ms 256 KB OK (n = 3, answer = YES)
8 Correct 5 ms 376 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 5 ms 376 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 5 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 376 KB OK (n = 2, answer = YES)
6 Correct 5 ms 376 KB OK (n = 3, answer = YES)
7 Correct 5 ms 256 KB OK (n = 3, answer = YES)
8 Correct 5 ms 376 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 5 ms 376 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 5 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -