제출 #541491

#제출 시각아이디문제언어결과실행 시간메모리
541491AmirElarbi마상시합 토너먼트 (IOI12_tournament)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define vi vector<int> #define ve vector #define ll long long #define vf vector<float> #define vll vector<pair<ll,ll>> #define ii pair<int,int> #define pll pair<ll,ll> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define mp make_pair #define fi first #define se second #define INF 2e9+5 #define eps 1e-7 #define eps1 1e-25 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define MAX_A 1e5+5 #define V 450 using namespace std; const int MOD = 1e9; const int nax = 1e5+5; int st[nax*4]; void update(int v, int l, int r, int pos, int val){ if(r < pos || l > pos) return; if(l == r){ st[v] += val; return; } int md = (l+r)/2; update(v*2,l,md,pos,val); update(v*2+1,md+1,r,pos,val); st[v] = st[v*2] +st[v*2+1]; } int query(int v, int l, int r, int i, int j){ if(r < i || l > j) return 0; if(i <= l && r <= j) return st[v]; int md = (l+r)/2; return query(v*2,l,md,i,j) + query(v*2+1,md+1,r,i,j); } int GetBestPosition(int n, int c, int r, int *k, int *s, int *e) { vi rngs(n); for (int i = 0; i < n; ++i) { rngs[i] = i; } for (int i = 0; i < c; ++i) { int lb = lower_bound(rngs.begin(), rngs.end(), s[i])-rngs.begin(); int ub = upper_bound(rngs.begin(), rngs.end(), e[i])-rngs.begin()-1; for (int j = lb; j <= ub; ++j) rngs[j] = rngs[lb]; for (int j = ub+1; j < n; ++j) rngs[j] -= (e[i]-s[i]); s[i] = lb,e[i] = ub; } int mx = 0, ps = 0; for (int i = 0; i < n; ++i) { int res = 0, ind = i; for (int j = 0; j < c; ++j) { if(s[j] <= i && i <= e[j]){ int cur =0; for (int ar = s[j]; ar < e[j]; ++ar) { cur = max(cur, k[ar]); } if(cur < r) res++; else break; } } if(res > mx){ mx = res; ps = i; } } return ps; } int main() { optimise; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n,c,r; cin >> n >> c >> r; int k[n],s[c],e[c]; for (int i = 0; i < n-1; ++i) { cin >> k[i]; } for (int i = 0; i < c; ++i) { cin >> s[i] >> e[i]; } cout << GetBestPosition(n,c,r,k,s,e) << endl; }

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

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