답안 #164667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164667 2019-11-22T12:52:37 Z aggu_01000101 Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 504 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> arr){
    vector<pair<int, int>> arr1;
    for(int i = 0;i<arr.size();i++){
        arr1.push_back(make_pair(arr[i], i));
    }
    vector<int> answer;
    int first = 0, last = 0;
    int sum = 0;
    while(last<arr1.size() && first<arr.size()){
        if(sum>=l && sum<=u){
            for(int i = first;i<last;i++){
                answer.push_back(arr1[i].second+1);
            }
            goto returnanswer;
        }
        else if(sum<l){
            sum+=arr1[last].first;
            last++;
        }
        else{
            sum-=arr1[first].first;
            first++;
        }
    }
    returnanswer:
    return answer;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<arr.size();i++){
                   ~^~~~~~~~~~~
molecules.cpp:13:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(last<arr1.size() && first<arr.size()){
           ~~~~^~~~~~~~~~~~
molecules.cpp:13:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(last<arr1.size() && first<arr.size()){
                               ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB OK (n = 12, answer = YES)
2 Correct 2 ms 376 KB OK (n = 12, answer = YES)
3 Correct 2 ms 256 KB OK (n = 12, answer = NO)
4 Correct 2 ms 376 KB OK (n = 12, answer = NO)
5 Incorrect 2 ms 376 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -