제출 #372583

#제출 시각아이디문제언어결과실행 시간메모리
372583cpp219Detecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms512 KiB
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2e5 + 9;
const ll mod = 1e9 + 7;

vector<int> kq;
void Get_kq(deque<ll> &dq){
    for (auto i : dq) kq.push_back(i);
}

vector<int> find_subset(int L,int R, vector<int> w){
    deque<ll> ans;
    vector<LL> a;
    ll cur = 0; ll n = w.size();
    for (ll i = 0;i < n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end());
    if (R < a[0].fs) return kq;
    if (L <= a[0].fs&&a[0].fs <= R){
        kq.push_back(a[0].sc); return kq;
    }
    if (L <= a[n - 1].fs&&a[n - 1].fs <= R){
        kq.push_back(a[n - 1].sc); return kq;
    }
    for (ll i = 0;i < n;i++){
        if (cur + a[i].fs <= R) cur += a[i].fs,ans.push_back(a[i].sc);
        else if (L <= cur&&cur <= R){
            Get_kq(ans); return kq;
        }
        else if (cur + a[i].fs > R){
            while(i < n){
                if (L <= cur&&cur <= R){
                    Get_kq(ans); return kq;
                }
                if (ans.empty()) break;
                ll p = ans.front(); ans.pop_front();
                ll val = a[i].fs - a[p].fs;
                if (cur + val <= R) cur += val,ans.push_back(a[i].sc); i++;
            }
            return kq;
        }
    }
}

/*

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    ll L,R,n,x; vector<int> w;
    cin>>L>>R>>n;
    for (ll i = 1;i <= n;i++) cin>>x,w.push_back(x);
    vector<int> c = find_subset(L,R,w);
    if (c.size()) cout<<1;
    else cout<<0;
}
*/

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

molecules.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
molecules.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   24 |     for (ll i = 0;i < n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end());
      |     ^~~
molecules.cpp:24:53: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |     for (ll i = 0;i < n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end());
      |                                                     ^~~~
molecules.cpp:45:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   45 |                 if (cur + val <= R) cur += val,ans.push_back(a[i].sc); i++;
      |                 ^~
molecules.cpp:45:72: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   45 |                 if (cur + val <= R) cur += val,ans.push_back(a[i].sc); i++;
      |                                                                        ^
molecules.cpp:21:15: warning: control reaches end of non-void function [-Wreturn-type]
   21 |     deque<ll> ans;
      |               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...