답안 #209340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209340 2020-03-13T20:42:09 Z mode149256 Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 376 KB
/*input

*/
#include <bits/stdc++.h>
#include "molecules.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

vi find_subset(int l, int u, vi w) {

	int N = (int)w.size();
	ll r = u;
	ll le = l;
	vpl sk(N);
	for (int i = 0; i < N; ++i)
		sk[i] = {w[i], i};

	sort(sk.begin(), sk.end());

	ll curr = sk[0].x;
	set<ll> ats = {sk[0].y};

	int j = 1;

	for (int i = 0; i < N; ++i)
	{
		while (j < N and curr + sk[j].x < l) {
			curr += sk[j].x;
			ats.insert(sk[j].y);
			j++;
		}

		if (l <= curr and curr <= r)
			return vi(ats.begin(), ats.end());

		curr -= sk[i].x;
		ats.erase(sk[i].y);
	}
	return vi(0);
}

Compilation message

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:62:5: warning: unused variable 'le' [-Wunused-variable]
  ll le = l;
     ^~
# 결과 실행 시간 메모리 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 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 376 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 376 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 376 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 376 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 376 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -