Submission #157131

#TimeUsernameProblemLanguageResultExecution timeMemory
157131NachoLibreArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
using namespace std; queue<int> q[2][200005]; bool bo[200005]; int ft[200005]; void gnk(int i) { while(i < 200005) { ++ft[i]; i += (i & -i); } } int pay(int i) { int tp = 0; while(i > 0) { tp += ft[i]; i -= (i & -i); } return tp; } long long count_swaps(int[] s) { long long rp = 0; int n = sizeof(s), payi = 0, a[n + 1]; for(int i = 1; i <= n; ++i) { a[i] = s[i - 1]; } for(int i = 1; i <= n; ++i) { if(a[i] < 0) q[0][-a[i]].push(i); else q[1][a[i]].push(i); } for(int i = 1; i <= n; ++i) { if(!bo[i]) { if(a[i] > 0) { q[1][a[i]].pop(); rp += q[0][a[i]].front() - i - (pay(q[0][a[i]].front()) - payi); gnk(q[0][a[i]].front()); bo[q[0][a[i]].front()] = 1; q[0][a[i]].pop(); } else { q[0][-a[i]].pop(); rp += q[1][-a[i]].front() - i - 1 - (pay(q[1][-a[i]].front()) - payi); gnk(q[1][-a[i]].front()); bo[q[1][-a[i]].front()] = 1; q[1][-a[i]].pop(); } } else { ++payi; } } return rp; }

Compilation message (stderr)

shoes.cpp:3:1: error: 'queue' does not name a type
 queue<int> q[2][200005];
 ^~~~~
shoes.cpp:23:29: error: expected ',' or '...' before 's'
 long long count_swaps(int[] s) {
                             ^
shoes.cpp: In function 'long long int count_swaps(int*)':
shoes.cpp:25:20: error: 's' was not declared in this scope
     int n = sizeof(s), payi = 0, a[n + 1];
                    ^
shoes.cpp:27:9: error: 'a' was not declared in this scope
         a[i] = s[i - 1];
         ^
shoes.cpp:30:12: error: 'a' was not declared in this scope
         if(a[i] < 0) q[0][-a[i]].push(i);
            ^
shoes.cpp:30:22: error: 'q' was not declared in this scope
         if(a[i] < 0) q[0][-a[i]].push(i);
                      ^
shoes.cpp:31:14: error: 'q' was not declared in this scope
         else q[1][a[i]].push(i);
              ^
shoes.cpp:35:16: error: 'a' was not declared in this scope
             if(a[i] > 0) {
                ^
shoes.cpp:36:17: error: 'q' was not declared in this scope
                 q[1][a[i]].pop();
                 ^
shoes.cpp:37:75: error: 'payi' was not declared in this scope
                 rp += q[0][a[i]].front() - i - (pay(q[0][a[i]].front()) - payi);
                                                                           ^~~~
shoes.cpp:37:75: note: suggested alternative: 'pay'
                 rp += q[0][a[i]].front() - i - (pay(q[0][a[i]].front()) - payi);
                                                                           ^~~~
                                                                           pay
shoes.cpp:42:17: error: 'q' was not declared in this scope
                 q[0][-a[i]].pop();
                 ^
shoes.cpp:43:81: error: 'payi' was not declared in this scope
                 rp += q[1][-a[i]].front() - i - 1 - (pay(q[1][-a[i]].front()) - payi);
                                                                                 ^~~~
shoes.cpp:43:81: note: suggested alternative: 'pay'
                 rp += q[1][-a[i]].front() - i - 1 - (pay(q[1][-a[i]].front()) - payi);
                                                                                 ^~~~
                                                                                 pay
shoes.cpp:49:15: error: 'payi' was not declared in this scope
             ++payi;
               ^~~~
shoes.cpp:49:15: note: suggested alternative: 'pay'
             ++payi;
               ^~~~
               pay