Submission #1002181

# Submission time Handle Problem Language Result Execution time Memory
1002181 2024-06-19T10:44:13 Z son2008 Difference (POI11_roz) C++17
Compilation error
0 ms 0 KB
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:3:1: error: 'string' does not name a type
    3 | string s;
      | ^~~~~~
roz.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int> pos[26];
      | ^~~~~~
roz.cpp:6:12: error: 'vector' was not declared in this scope
    6 | int maxSub(vector<int> &arr){
      |            ^~~~~~
roz.cpp:6:19: error: expected primary-expression before 'int'
    6 | int maxSub(vector<int> &arr){
      |                   ^~~
roz.cpp: In function 'void solve()':
roz.cpp:17:5: error: 'cin' was not declared in this scope
   17 |     cin >> n >> s;
      |     ^~~
roz.cpp:17:17: error: 's' was not declared in this scope
   17 |     cin >> n >> s;
      |                 ^
roz.cpp:18:9: error: 'i' was not declared in this scope
   18 |     rep(i, n)
      |         ^
roz.cpp:18:5: error: 'rep' was not declared in this scope
   18 |     rep(i, n)
      |     ^~~
roz.cpp:35:5: error: 'cout' was not declared in this scope
   35 |     cout << ans;
      |     ^~~~