제출 #769186

#제출 시각아이디문제언어결과실행 시간메모리
769186AndreyArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long haha[200001][19]; void add(long long a) { for(long long i = 0; i < 19; i++) { a-=(a%(1 << i)); haha[a][i]++; } } long long calc(long long a, long long b) { long long j = 0; long long ans = 0; while(a < b) { j = 0; while(a%(1 << j) == 0 && a+(1 << j) <= b) { j++; } j--; ans+=haha[a][j]; a+=(1 << j); } return ans+haha[b][0]; } long long count_swaps(int[] s) { const long long y = 100000; long long n = (*(&s + 1) - s)/2,p,a,ans = 0; for(long long i = 0; i < 200001; i++) { for(long long j = 0; j < 19; j++) { haha[i][j] = 0; } } vector<long long> bruh(2*n); vector<vector<long long>> yeah(200001); for(long long i = 0; i < 2*n; i++) { bruh[i] = s[i]; } for(long long i = 2*n-1; i >= 0; i--) { yeah[bruh[i]+y].push_back(i); } for(long long i = 0; i < 2*n; i++) { if(bruh[i] != -INT_MAX) { while(yeah[-bruh[i]+y][yeah[-bruh[i]+y].size()-1] < i) { yeah[-bruh[i]+y].pop_back(); } if(bruh[i] < 0) { p = yeah[-bruh[i]+y][yeah[-bruh[i]+y].size()-1]; a = 0; } else { p = yeah[-bruh[i]+y][yeah[-bruh[i]+y].size()-1]; a = 1; } yeah[-bruh[i]+y].pop_back(); bruh[p] = -INT_MAX; ans += p-i-1-calc(i,p-1)+a; add(p); add(i); } } cout << ans; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp:28:29: error: expected ',' or '...' before 's'
   28 | long long count_swaps(int[] s) {
      |                             ^
shoes.cpp: In function 'long long int count_swaps(int*)':
shoes.cpp:30:23: error: 's' was not declared in this scope
   30 |     long long n = (*(&s + 1) - s)/2,p,a,ans = 0;
      |                       ^
shoes.cpp:50:17: error: 'p' was not declared in this scope
   50 |                 p = yeah[-bruh[i]+y][yeah[-bruh[i]+y].size()-1];
      |                 ^
shoes.cpp:51:17: error: 'a' was not declared in this scope
   51 |                 a = 0;
      |                 ^
shoes.cpp:54:17: error: 'p' was not declared in this scope
   54 |                 p = yeah[-bruh[i]+y][yeah[-bruh[i]+y].size()-1];
      |                 ^
shoes.cpp:55:17: error: 'a' was not declared in this scope
   55 |                 a = 1;
      |                 ^
shoes.cpp:58:18: error: 'p' was not declared in this scope
   58 |             bruh[p] = -INT_MAX;
      |                  ^
shoes.cpp:59:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   59 |             ans += p-i-1-calc(i,p-1)+a;
      |             ^~~
      |             abs
shoes.cpp:59:38: error: 'a' was not declared in this scope
   59 |             ans += p-i-1-calc(i,p-1)+a;
      |                                      ^
shoes.cpp:64:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |     cout << ans;
      |             ^~~
      |             abs