Submission #117999

#TimeUsernameProblemLanguageResultExecution timeMemory
117999rajarshi_basuJousting tournament (IOI12_tournament)C++14
0 / 100
1074 ms1788 KiB
#include <iostream> #include <vector> #include <set> #include <iomanip> #include <algorithm> #include <functional> #include <stdio.h> #include <cmath> #include <queue> #include <string> #include <map> #include <fstream> #include <complex> #include <stack> #include <set> #define FOR(i,n) for(int i=0;i<n;i++) #define FORE(i,a,b) for(int i=a;i<=b;i++) #define ll long long int #define vi vector<int> #define ii pair<int,int> #define pb push_back #define mp make_pair #define ff first #define ss second #define pll pair<ll,ll> #define cd complex<double> #define ld long double #define pld pair<ld,ld> #define iii pair<ii,int> using namespace std; const ll INF = 1e9+10; const int MAXN = 100*100*10+10; int elimArray[MAXN];//means after the ith cell, elimArray[i] had been eliminated. vector<ii> modifRange; int prevBest[MAXN]; int nextBest[MAXN]; int GetBestPosition(int n,int c,int r,int* arr,int* ss,int* ee){ // first modify the range to their actual sizes; // this step is O(n^2) for now. change to O(nlogn) later. FOR(i,c){ int s = ss[i]; int e = ee[i]; int ctr = 0; FORE(j,s,e){ ctr += elimArray[j]; } modifRange.pb({s,e+ctr}); elimArray[s] += e-s; } // now for each position, find its closest left and right element greater than r; // this step is already O(n) int bestFound = -1; FOR(i,n-1){ prevBest[i] = bestFound; if(arr[i] > r)bestFound = i; } prevBest[n-1] = bestFound; bestFound = n; for(int i = n-2;i>=0;i--){ nextBest[i+1] = bestFound; if(arr[i] > r)bestFound = i; } nextBest[0] = bestFound; /* FOR(i,n-1)cout << arr[i] << " ";cout << endl; for(auto e: modifRange){ cout << e.ff << " " << e.ss << endl; } cout << endl; FOR(i,n-1)cout << prevBest[i] << " ";cout << endl; FOR(i,n-1)cout << nextBest[i] << " ";cout << endl; */ int mx = 0; FOR(i,n){ int hit = 0; for(auto e : modifRange){ if(e.ss < i or e.ff > i)continue; int mm = 0; FORE(j,e.ff,e.ss-1)mm = max(arr[j],mm); if(mm == r){ hit++; }else { break; } if(e.ff <= prevBest[i] or e.ss >= nextBest[i]+1){ //break; } //hit++; } //cout <<i << " " << hit << endl; mx = max(mx,hit); } return mx; } int ma1in(){ int arr[4]; int s[3] = {1,0,0}; int e[3] = {3,1,1}; cout << GetBestPosition(5,3,3,arr,s,e) << endl; }

Compilation message (stderr)

tournament.cpp: In function 'int ma1in()':
tournament.cpp:108:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...