제출 #549926

#제출 시각아이디문제언어결과실행 시간메모리
549926Bogdan1110Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);} #define ll long long #define ull unsigned long long #define pb push_back #define fi first #define se second #define ld long double #define pii pair<int,int> #define pll pair<long long,long long> #define all(a) (a).begin(), (a).end() #define mp make_pair using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> // order_of_key -> # less than k // find_by_order -> k-th element // pq max element void files() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } const double eps = 0.00000001; const int NMAX = 200010; const ll inf = LLONG_MAX/2; const ll modi = 1e9+7; vector<int> find_subset(int l, int r, vector<int>w) { int n = w.size(); vector<pll>v(n); for (int i = 0 ; i < n ; i++ ) { v[i] = {w[i],i}; } sort(all(v)); int L = 0, R = 0; ll sum = 0; vector<int>ans; while(R<n) { cout << L << ' ' << R << endl; if ( sum < l ) { sum += v[R].fi; R++; continue; } if ( sum > r ) { sum -= v[L].fi; L++; continue; } for (int i = L ; i < R ; i++ ) { ans.pb(v[i].se); } break; } sort(all(ans)); return ans; } void solve () { int l,r; cin >> l >> r ; int n; cin >> n; vector<int>v(n); for (int i = 0 ; i < n ; i++ ) cin >> v[i]; vector<int>ans = find_subset(l,r,v); cout << ans.size() << endl ; for (auto u : ans) cout << u << ' '; } int main () { files(); FAST int t=1; //cin >> t; int i = 1; while(t--) { //cout << "Case #" << i++ << ": " ; solve(); } }

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

molecules.cpp: In function 'int main()':
molecules.cpp:81:9: warning: unused variable 'i' [-Wunused-variable]
   81 |     int i = 1;
      |         ^
molecules.cpp: In function 'void files()':
molecules.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
molecules.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cchEe1jz.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccd1oPFz.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status