Submission #24494

# Submission time Handle Problem Language Result Execution time Memory
24494 2017-06-09T11:15:29 Z Donghyun Kim(#1043) Detecting Molecules (IOI16_molecules) C++
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n, S, E, id[200010];
ll s[200010];

vector<int> get(int k){
    int st = 1, en = n - k + 1;
    while(st <= en){
		int m = (st + en) / 2;
		if(s[m + k - 1] - s[m - 1] >= S) en = m - 1;
		else st = m + 1;
    }
	if(st >= 1 && st + k - 1 <= n && s[st + k - 1] - s[st - 1] <= E){
		vector<int> v;
		for(int i = st; i < st + k; i++) v.push_back(id[i]);
		return v;
	}
	return vector<int>();
}

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<pii> v;
    int cnt = 0;
    for(auto &i : w){
		v.push_back({i, cnt++});
    }
    sort(v.begin(), v.end());
    S = l; E = u;
    for(auto &i : v){
		s[++n] = s[n - 1] + i.first;
		id[n] = i.second;
    }
    for(int i = 1; i <= n; i++){
		vector<int> t = get(i);
		if(!t.empty()) return t;
    }
    return vector<int>();
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:28:9: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
     for(auto &i : w){
         ^
molecules.cpp:28:15: error: ISO C++ forbids declaration of 'i' with no type [-fpermissive]
     for(auto &i : w){
               ^
molecules.cpp:28:19: warning: range-based 'for' loops only available with -std=c++11 or -std=gnu++11
     for(auto &i : w){
                   ^
molecules.cpp:29:15: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   v.push_back({i, cnt++});
               ^
molecules.cpp:29:25: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   v.push_back({i, cnt++});
                         ^
molecules.cpp:33:9: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
     for(auto &i : v){
         ^
molecules.cpp:33:15: error: ISO C++ forbids declaration of 'i' with no type [-fpermissive]
     for(auto &i : v){
               ^
molecules.cpp:33:19: warning: range-based 'for' loops only available with -std=c++11 or -std=gnu++11
     for(auto &i : v){
                   ^
molecules.cpp:34:25: error: request for member 'first' in 'i', which is of non-class type 'int'
   s[++n] = s[n - 1] + i.first;
                         ^
molecules.cpp:35:13: error: request for member 'second' in 'i', which is of non-class type 'int'
   id[n] = i.second;
             ^