제출 #1187023

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

vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	vector <pair <int, int>> p;
	p.push_back({0, 0});
	for (int i = 0;i < n;i++) {
		p.push_back({w[i], i});
	}
	sort(p.begin(), p.end());
	vector <int> res;
	int l = 1, r = 1;
	int suml = 0, sumr = 0;
	while (r <= n && l <= n) {
		if (sumr - suml < l) {
			sumr += p[r].first;
			r++;
		}
		if (p[r - 1].first - p[l - 1].first > u - l) {
			suml += p[l].first;
			l++;
		}
		if (sumr - suml > u) {
			suml += p[l].first;
			l++;
		}
		if (sumr - suml <= u && sumr - suml >= l && p[r].first - p[l].first <= u - l) {
			while (l <= r) {
				res.push_back(p[i].second);
			}
			return res;
		}
	}
	return res;
}

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

molecules.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:13: error: declaration of 'int l' shadows a parameter
   14 |         int l = 1, r = 1;
      |             ^
molecules.cpp:5:29: note: 'int l' previously declared here
    5 | vector<int> find_subset(int l, int u, vector<int> w) {
      |                         ~~~~^
molecules.cpp:31:49: error: 'i' was not declared in this scope
   31 |                                 res.push_back(p[i].second);
      |                                                 ^
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
      |         ^~~~