제출 #1003801

#제출 시각아이디문제언어결과실행 시간메모리
1003801vjudge1Ekoeko (COCI21_ekoeko)C++17
110 / 110
20 ms4028 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int maxa = 30; const int maxn = 2e5 + 10; vector<int> bit(maxn), ocorrencias[maxa]; void update( int id, int val ){ for( int i = id; i < maxn; i += i&-i ) bit[i] += val; } int query( int id ){ int sum = 0; for( int i = id; i > 0; i -= i&-i ) sum += bit[i]; return sum; } int main(){ int n; cin >> n; for( int i = 1; i <= 2*n; i++ ){ char c; cin >> c; ocorrencias[c - 'a'].push_back(i); } vector<pair<int, int>> original; for( int i = 0; i < 26; i++ ) for( int j = 0; j < ocorrencias[i].size()/2; j++ ) original.push_back({ ocorrencias[i][j], i }); sort( original.begin(), original.end() ); vector<int> cont(maxa), v(2*n + 1); for( int i = 0; i < original.size(); i++){ int letra = original[i].second; v[ocorrencias[letra][cont[letra]]] = i + 1; v[ocorrencias[letra][cont[letra] + ocorrencias[letra].size()/2]] = n + i + 1; cont[letra]++; } ll resp = 0; for( int i = 1; i <= 2*n; i++ ){ update(v[i], 1); int inversoes = i - query(v[i]); resp += inversoes; } cout << resp << endl; }

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

Main.cpp: In function 'int main()':
Main.cpp:19:51: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for( int i = 0; i < 26; i++ ) for( int j = 0; j < ocorrencias[i].size()/2; j++ ) original.push_back({ ocorrencias[i][j], i });
      |                                                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for( int i = 0; i < original.size(); i++){
      |                   ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...