제출 #972718

#제출 시각아이디문제언어결과실행 시간메모리
972718vjudge1Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <sstream> #include "molecules.h" using namespace std; #define accepted ios_base::sync_with_stdio(false);cin.tie(nullptr); #define Daulbekov signed #define Makan main #define int long long #define double long double #define pb push_back #define pf push_front #define F first #define S second const int N=2e5+7; const int MAX=9e18+7; const int INF=1e18; vector<int>find_subset(int l,int u,vector<int>w){ pair<int,int>w1; for(int i=0;i<w.size();i++){ w1[i].F=w[i]; w1[i].S=i; } sort(w1.begin(),w1.end()); int l1=0,r1=0,sum=w1[0].F; vector<int>ans; while(l1<n&&r1<n){ if(l<=sum&&sum<=u){ for(int i=l1;i<=r1;i++)ans.pb(w1[i].S); break; } else if(l>sum){ r1++; sum+=w1[r1].F; } else if(sum>u){ sum-=w1[l1].F; l++; } } return ans; } //Daulbekov Makan(){ // accepted; // //} // 2 2 4 // 2 2 2 // 3 2 1 3 2 1 3 3 // 3 2 1 3 2 1

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

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:19:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for(int i=0;i<w.size();i++){
      |              ~^~~~~~~~~
molecules.cpp:20:5: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'long long int')
   20 |   w1[i].F=w[i];
      |     ^
molecules.cpp:21:5: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'long long int')
   21 |   w1[i].S=i;
      |     ^
molecules.cpp:23:10: error: 'struct std::pair<long long int, long long int>' has no member named 'begin'
   23 |  sort(w1.begin(),w1.end());
      |          ^~~~~
molecules.cpp:23:21: error: 'struct std::pair<long long int, long long int>' has no member named 'end'
   23 |  sort(w1.begin(),w1.end());
      |                     ^~~
molecules.cpp:24:22: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'int')
   24 |  int l1=0,r1=0,sum=w1[0].F;
      |                      ^
molecules.cpp:26:11: error: 'n' was not declared in this scope
   26 |  while(l1<n&&r1<n){
      |           ^
molecules.cpp:28:36: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'long long int')
   28 |    for(int i=l1;i<=r1;i++)ans.pb(w1[i].S);
      |                                    ^
molecules.cpp:33:11: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'long long int')
   33 |    sum+=w1[r1].F;
      |           ^
molecules.cpp:36:11: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'long long int')
   36 |    sum-=w1[l1].F;
      |           ^