Submission #1002183

# Submission time Handle Problem Language Result Execution time Memory
1002183 2024-06-19T10:45:11 Z son2008 Difference (POI11_roz) C++14
Compilation error
0 ms 0 KB
 #include<bits/stdc++.h>
    using namespace std;
const int N = 1e6 + 5;
int n;
string s;
vector<int> pos[26];

int maxSub(vector<int> &arr){
    int res = 0, Min = 0;
    FOR(i,1,(int)arr.size()-1){
        arr[i] += arr[i-1];
        if (arr[i] != i) res = max(res, arr[i] - Min);
        Min = min(Min, arr[i]);
    }
    return res;
}

void solve(){
    cin >> n >> s;
    rep(i, n)
        pos[s[i] - 'a'].pb(i);
    int ans = 0;
    rep(i, 26)
        FOR(j,i+1,25){
            vector<int> arr(1, 0), tmp;
            int l=0, r=0;
            while(l < pos[i].size() && r < pos[j].size())
                if (pos[i][l] < pos[j][r]) arr.pb(+1), l++;
                else arr.pb(-1), r++;
            while(l < pos[i].size()) arr.pb(+1), l++;
            while(r < pos[j].size()) arr.pb(-1), r++;

            tmp = arr;
            for(int &v : tmp) v = -v; 
            ans = max({ans, maxSub(arr), maxSub(tmp)});
        }
    cout << ans;
}

Compilation message

roz.cpp: In function 'int maxSub(std::vector<int>&)':
roz.cpp:10:9: error: 'i' was not declared in this scope
   10 |     FOR(i,1,(int)arr.size()-1){
      |         ^
roz.cpp:10:5: error: 'FOR' was not declared in this scope
   10 |     FOR(i,1,(int)arr.size()-1){
      |     ^~~
roz.cpp:9:18: warning: unused variable 'Min' [-Wunused-variable]
    9 |     int res = 0, Min = 0;
      |                  ^~~
roz.cpp: In function 'void solve()':
roz.cpp:20:9: error: 'i' was not declared in this scope
   20 |     rep(i, n)
      |         ^
roz.cpp:20:5: error: 'rep' was not declared in this scope
   20 |     rep(i, n)
      |     ^~~