Submission #102152

# Submission time Handle Problem Language Result Execution time Memory
102152 2019-03-23T01:50:16 Z royyaha Detecting Molecules (IOI16_molecules) C++11
Compilation error
0 ms 0 KB
#include "molecules.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define rep0(i, n) rep(i, 0, n)
#define rep1(i, n) rep(i, 1, n+1)
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define IOS cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define _ << " " << 
#define endl '\n'
#define wer(x) cout << (#x) << "->" << (x) << endl;
#define we(x) (#x) << ":(" << x << ") "
//////////////////////////////////////////////////////////////////
#define __lg(i) log(i) / log(2)

const int maxn = 2e5+50;
vector<ii> item;

vector<int> solve(int l, int r, vector<int> w) {
	int n = (int) w.size();
	rep0(i, n) item.eb(w[i], i + 1);
	sort(item.begin(), item.end());
	vector<int> ans;
	queue<ii> q;
	int sum = 0;
	for(auto i : item) {
		while(q.empty() != false && i.fs - q.front().fs > r - l) sum -= q.front().fs, q.pop();
		q.push(i); sum += i.fs;
		while(q.empty() != false && sum > l) {
			sum -= q.front().fs, q.pop();
		}
		if(sum >= r) {
			while(q.empty() != false) {
				ans.pb(q.front().sc);
				q.pop();
			}
		}
	}
	sort(ans.begin(), ans.end());
	return ans;


}



Compilation message

molecules.cpp: In function 'std::vector<int> solve(int, int, std::vector<int>)':
molecules.cpp:29:2: error: 'sort' was not declared in this scope
  sort(item.begin(), item.end());
  ^~~~
molecules.cpp:29:2: note: suggested alternative: 'short'
  sort(item.begin(), item.end());
  ^~~~
  short
molecules.cpp:31:2: error: 'queue' was not declared in this scope
  queue<ii> q;
  ^~~~~
molecules.cpp:31:10: error: expected primary-expression before '>' token
  queue<ii> q;
          ^
molecules.cpp:31:12: error: 'q' was not declared in this scope
  queue<ii> q;
            ^