이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=1e5+5;
int pos[MAX*2];
ll count_swaps(vi tab)
{
int ans=0;
int n=sz(tab);
int ile=sz(tab)/2;
for (int i=0;i<n-1;i+=2)
{
int wsk=0;
wsk=-tab[i];
int akt=-1e6+5;
for (int j=i+1;j<n;j++)
{
if (tab[j]==wsk)
{
akt=j;
break;
}
}
// cout<<"TERAZ "<<akt<<" "<<wsk<<"\n";
if (akt>i)
{
for (int j=akt;j>=i+2;j--)swap(tab[j],tab[j-1]),ans++;
if (tab[i]>tab[i+1])swap(tab[i],tab[i+1]),ans++;
}
else if (tab[i]>tab[i+1])swap(tab[i],tab[i+1]),ans++;
//cout<<"ZAWARTOSC "<<n<<"\n";
//for (auto it:tab)cout<<it<<" ";
//cout<<"\n";
}
return ans;
}
/*
int main()
{
cout<<count_swaps({-2, 2, 2, -2, -2, 2});
}
*/
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:22:6: warning: unused variable 'ile' [-Wunused-variable]
int ile=sz(tab)/2;
^~~
# | 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... |