제출 #1141032

#제출 시각아이디문제언어결과실행 시간메모리
1141032SG2AlokDetecting Molecules (IOI16_molecules)C++20
컴파일 에러
0 ms0 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<int> ans;
	vector<pair<int, int>> nw;
	
	for(int i = 0; i < nw.size(); i++){
		nw.push_back({w[i], i});
	}
	
	sort(nw.begin(), nw.end());
	
	long long sum = 0;
	for(int i = 0, j = 0; j < nw.size(); j++){
		sum += nw[j].fi;
		while(sum > u){
			sum -= nw[i++].fi;
		}
		
		if(sum >= l && sum <= u){
			for(int k = i; k <= j; k++){
				ans.push_back(nw[k].se);
			}
			
			break;
		}
	}
	
	return ans;
}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:30: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   17 |                 sum += nw[j].fi;
      |                              ^~
molecules.cpp:19:40: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   19 |                         sum -= nw[i++].fi;
      |                                        ^~
molecules.cpp:24:53: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'se'
   24 |                                 ans.push_back(nw[k].se);
      |                                                     ^~
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~