Submission #785675

# Submission time Handle Problem Language Result Execution time Memory
785675 2023-07-17T12:02:37 Z aymanrs Shortcut (IOI16_shortcut) C++14
Compilation error
0 ms 0 KB
    #include<bits/stdc++.h>
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
    using namespace std;
    long long find_shortcut(int n, vector<int> l, vector<int> d, int c){
    	long long L = 1, R = (long long)1e9 * (n+1), M, B = R;
    	long long t[n];
    	pair<long long, long long> mtd[n][n];
    	t[0] = 0;
    	for(int i = 1;i < n;i++) t[i] = l[i-1]+t[i-1];
    	for(int i = 0;i < n;i++){
    		for(int j = i+1;j < n;j++){
    			mtd[i][j-i-1] = make_pair(t[j]+d[j], t[j]-d[j]);
    		}
    		sort(mtd[i], mtd[i]+n-i-1);
    		long long nex = LONG_LONG_MAX;
    		for(int j = n-1;j > i;j--){
    			nex = mtd[i][j-i-1].second = min(mtd[i][j-i-1].second, nex); 
    		}
    	}
    	while(L <= R){
    		M = L+(R-L)/2;
    		bool ok = false;
    		long long sp[n];
    		for(int j = 0;j < n-1;j++){
    			if(mtd[j][n-j-2].first-t[j]+d[j] <= M) continue;
    			sp[j] = lower_bound(mtd[j], mtd[j]+n-j-1, make_pair(M+t[j]-d[j]+1, LONG_LONG_MIN))->second;
    		}
    		for(int i = 0;i < n && !ok;i++){
              #pragma GCC ivdep
    			long long le = 0, re = LONG_LONG_MAX;
    			for(int j = i;j < n-1;j++){
                  #pragma GCC ivdep
    				if(mtd[j][n-j-2].first-t[j]+d[j] <= M) continue;
    				long long ld = t[j]-t[i]+d[j]+c-M;
    				le = max(le, ld+mtd[j][n-j-2].first);
    				re = min(re, sp[j]-ld);
    			}
    			for(int j = 0;j < i;j++){
                  #pragma GCC ivdep
    				if(mtd[j][n-j-2].first-t[j]+d[j] <= M) continue;
    				long long ld = t[i]-t[j]+d[j]+c-M;
    				le = max(le, ld+mtd[j][n-j-2].first);
    				re = min(re, sp[j]-ld);
    			}
    			for(int j=0;j < n && !ok;j++){
                  #pragma GCC ivdep
                  ok |= le <= t[j] && t[j] <= re; 
                }
    		}
    		if(ok) {
    			R = M-1;
    			B = M;
    		} else L = M+1;
    	}
    	return B;
    }
    // int main(){
    // 	cout << find_shortcut(9, {10, 10, 10, 10, 10, 10, 10, 10},{20, 0, 30, 0, 0, 40, 0, 40, 0}, 30) << '\n';
    // }

Compilation message

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:31:8: error: for, while or do statement expected before 'long'
   31 |        long long le = 0, re = LONG_LONG_MAX;
      |        ^~~~
shortcut.cpp:34:9: error: for, while or do statement expected before 'if'
   34 |         if(mtd[j][n-j-2].first-t[j]+d[j] <= M) continue;
      |         ^~
shortcut.cpp:41:9: error: for, while or do statement expected before 'if'
   41 |         if(mtd[j][n-j-2].first-t[j]+d[j] <= M) continue;
      |         ^~
shortcut.cpp:48:19: error: for, while or do statement expected before 'ok'
   48 |                   ok |= le <= t[j] && t[j] <= re;
      |                   ^~