제출 #239622

#제출 시각아이디문제언어결과실행 시간메모리
239622ant101Arranging Shoes (IOI19_shoes)C++14
10 / 100
1096 ms384 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <iomanip> #include <fstream> #include <cmath> #include <vector> #include <set> #include <unordered_set> #include <unordered_map> #include <map> #include <stack> #include <queue> #include <assert.h> #include <limits> #include <cstdio> #include <shoes.h> using namespace std; //#define RDEBUG 1 #ifdef RDEBUG #define D(x) x #else #define D(x) #endif #define inf 0x7fffffff #define MOD 1000000007 typedef long long ll; ll add(ll a, ll b) { a += b; if(a >= MOD) { a -= MOD; } return a; } ll sub(ll a, ll b) { a -= b; if(a < 0) { a += MOD; } return a; } ll mul(ll a, ll b) { return (a * b)%MOD; } void add_self(ll& a, ll b) { a = add(a, b); } void sub_self(ll& a, ll b) { a = sub(a, b); } void mul_self(ll& a, ll b) { a = mul(a, b); } const ll MAXN = 200010; ll tree[MAXN]; ll N; void update(ll ind, ll num) { while (ind<=MAXN) { tree[ind]+=num; ind+=(ind&-ind); } } ll getsum(ll ind) { ll sum = 0; while (ind) { sum+=tree[ind]; ind-=(ind&-ind); } return sum; } map<ll, ll> closest; ll closestind[MAXN]; ll vis[MAXN]; ll S[MAXN]; long long count_swaps(std::vector<int> s) { N = s.size(); for (ll i = 0; i<s.size(); i++) S[i+1] = s[i]; for (ll i = N; i>=1; i--) { if (closest.find(-S[i]) != closest.end()) { closestind[i] = closest[-S[i]]; } closest[S[i]] = i; } ll ans = 0; for (ll i = 1; i<=N; i++) { if (!vis[i]) { ans+=closestind[i]-i-1-(getsum(closestind[i])-getsum(i))+(S[i] > 0); update(closestind[i], 1); vis[closestind[i]] = 1; } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:90:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ll i = 0; i<s.size(); i++) S[i+1] = s[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...
#Verdict Execution timeMemoryGrader output
Fetching results...