제출 #785074

#제출 시각아이디문제언어결과실행 시간메모리
785074LyricallyDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define pb push_back #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) int read(){int x;scanf("%d",&x);return x;} void print(int x){printf("%d\n",x);} void file(string s) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } const int mod=998244353; vector<int> find_subset(int l,int r,vector<int> w) { vector<pii> v; rep(i,(int)w.size()) { v.pb({w[i],i}); } sort(v.begin(),v.end()); long long tot=0; int n=(int)w.size(); vector<int> res; rep(i,n) { tot=0; for(int j=i;j<n;j++) { tot+=v[j].first; if(tot>=l&&tot<=r) { for(int k=i;k<=j;k++) { res.pb(v[k].second); } sort(res.begin(),res.end()); return res; } } } return res; } signed main() { int n=read(),L=read(),R=read(); vector<int> w(n); rep(i,n){w[i]=read();} vector<int> cur=find_subset(L,R,w); cout<<cur.size()<<endl; rep(i,cur.size()) { cout<<cur[i]<<" "; } return 0; }

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

molecules.cpp: In function 'int main()':
molecules.cpp:5:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,n) for(int i=0;i<n;i++)
......
   52 |  rep(i,cur.size())
      |      ~~~~~~~~~~~~              
molecules.cpp:52:2: note: in expansion of macro 'rep'
   52 |  rep(i,cur.size())
      |  ^~~
molecules.cpp: In function 'int read()':
molecules.cpp:7:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | int read(){int x;scanf("%d",&x);return x;}
      |                  ~~~~~^~~~~~~~~
molecules.cpp: In function 'void file(std::string)':
molecules.cpp:11:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  freopen((s+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
molecules.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen((s+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccnZQzKo.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqzDw7m.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status