#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define print(l) for(auto i:l) cout<<i<<" ";cout<<endl;
#define input(t,l,n) vector<t>l(n);for(int i = 0;i<n;i++)cin>>l[i];
// #define int long long
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define all(l) l.begin(),l.end()
#define pii pair<int,int>
#define fi first
#define se second
const int M = 1e9+7;
const int inf = 1e18;
int bp(int x, int y, int p){
int res = 1;
x = x % p;
while (y > 0) {
if (y & 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
int MI(int n, int p){
return bp(n, p - 2, p);
}
int mul(int x,int y, int p){
return x * 1ull * y % p;
}
int di(int x,int y, int p){
return mul(x, MI(y, p), p);
}
// int n , m , k , q;
//
// void solve(int testcase_number){
// cin>>n;
//
// }
//
//
long long count_swaps(vector<int> s) {
long long ans = 0;
int n = s.size();
map<int,int>cnt;
for(int i = 0;i<n;i++){
cnt[abs(s[i])]++;
if(cnt[abs(s[i])]%2 == 0){
int x = i;
while(x-1>=0 and abs(s[x-1]) != abs(s[x])){
swap(s[x],s[x-1]);
x--;
ans++;
}
if(x-1 >= 0 and s[x] < s[x-1]){
swap(s[x],s[x-1]);
ans++;
}
}
}
// print(s);
return ans;
}
// int main(){
// cout<<count_swaps({2,1,-1,-2})<<endl;
// }
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp:16:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
16 | const int inf = 1e18;
| ^~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |