제출 #1354605

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

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<pair<int, int>> p;
    for(int i = 0; i < w.size(); i++) p.pb({w[i], i}); 
    sort(p.begin(), p.end());
    int l1 = 0, r = 0; 
    long long sum = 0;
    bool ok = 0;
    int n = w.size();
    while(r < n){
        if(sum >= l and sum <= u){ok = 1; break;}
        if(sum < l) r++, if(r != n) sum += p[r].fs;
        if(sum > u) sum -= p[l1].fs, l1++;
    }
    vector<int> ans;
    if(!ok) return ans;
    for(int i = l1; i < r; i++) ans.pb(p[i].sc);
    return ans; 
}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:18:26: error: expected primary-expression before 'if'
   18 |         if(sum < l) r++, if(r != n) sum += p[r].fs;
      |                          ^~