Submission #957336

# Submission time Handle Problem Language Result Execution time Memory
957336 2024-04-03T14:02:11 Z Alexabcde1 Detecting Molecules (IOI16_molecules) C++14
10 / 100
1000 ms 348 KB
#include "molecules.h"
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
long long ll,rr;
vector<pair<long long,long long> > ve;
vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector<int> ans;
    for (int i=0;i<w.size();i++){
        ve.push_back({w[i],i});
    }
    sort(ve.begin(),ve.end());
    for (int i=1;i<w.size();i++) ve[i].f+=ve[i-1].f;
    ll=0; rr=0;
    while (rr<w.size()){
        long long sum=ve[rr].f;
        if (ll!=0) sum-=ve[ll-1].f;
        if (l<=sum && sum<=u){
            for (int ii=ll;ii<=rr;ii++) ans.push_back(ve[ii].s);
            sort(ans.begin(),ans.end());
            return ans;
        }
        else if (sum<l) rr++;
        else {
            ll++;
            if (rr<ll) ll=rr;
        }
    }
    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i=0;i<w.size();i++){
      |                  ~^~~~~~~~~
molecules.cpp:14:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i=1;i<w.size();i++) ve[i].f+=ve[i-1].f;
      |                  ~^~~~~~~~~
molecules.cpp:16:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     while (rr<w.size()){
      |            ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Execution timed out 1058 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 12, answer = YES)
2 Correct 0 ms 348 KB OK (n = 12, answer = YES)
3 Correct 0 ms 348 KB OK (n = 12, answer = NO)
4 Correct 0 ms 344 KB OK (n = 12, answer = NO)
5 Correct 0 ms 348 KB OK (n = 12, answer = YES)
6 Correct 1 ms 348 KB OK (n = 12, answer = YES)
7 Correct 1 ms 348 KB OK (n = 12, answer = YES)
8 Correct 0 ms 348 KB OK (n = 12, answer = YES)
9 Correct 0 ms 348 KB OK (n = 6, answer = YES)
10 Correct 0 ms 348 KB OK (n = 12, answer = YES)
11 Correct 0 ms 348 KB OK (n = 100, answer = NO)
12 Correct 1 ms 348 KB OK (n = 100, answer = YES)
13 Correct 0 ms 348 KB OK (n = 100, answer = NO)
14 Correct 0 ms 348 KB OK (n = 100, answer = YES)
15 Correct 1 ms 348 KB OK (n = 100, answer = YES)
16 Correct 0 ms 348 KB OK (n = 100, answer = YES)
17 Correct 0 ms 348 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Execution timed out 1058 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Execution timed out 1058 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Execution timed out 1058 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Execution timed out 1058 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -