제출 #958954

#제출 시각아이디문제언어결과실행 시간메모리
958954IUA_HasinDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define endl "\n" #define yeap cout<<"YES"<<endl #define nope cout<<"NO"<<endl #define ll long long using namespace std; #include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<ll, ll>> v; for(int i=0; i<w.size(); i++){ ll a = w[i]; v.push_back({a, i}); } cout<<1<<endl; cout<<1<<endl; sort(v.begin(), v.end()); ll s = w.size(); ll arr[s+1]; arr[0] = 0; for(int i=0; i<s; i++){ ll a = v[i].first; arr[i+1] = arr[i]+a; } ll status = -1; ll q, r, k; for(int i=0; i<s; i++){ if(status==1){ break; } else { ll a = arr[i+1]-arr[0]; ll b = arr[s]-arr[s-i]; if(a<=u && b>=l){ ll aa = a; ll bb = 0; ll cnt = 0; q = 0; r = s-1; cout << aa << " " << bb << " " << i << endl; while(q<r || cnt<i+1){ if((aa+bb)>=l && (aa+bb)<=u){ status = 1; k = i+1; break; } else { ll c = w[q]; ll d = w[r]; aa = aa-c; bb = bb+d; q++; r--; cnt++; } } } } } if(status==-1){ return std::vector<int>(0); } else { vector<int> ans; k--; for(int i=q; i<=k; i++){ ans.push_back(v[i].second); } for(int i=s-1; i>=r; i--){ ans.push_back(v[i].second); } return ans; } }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0; i<w.size(); i++){
      |                  ~^~~~~~~~~
#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...