제출 #433006

#제출 시각아이디문제언어결과실행 시간메모리
433006MatijaLArranging Shoes (IOI19_shoes)C++14
0 / 100
1 ms204 KiB
/** * Author: MatijaL * Time: 2021-06-18 19:02:04 **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pll pair<ll, ll> #define loop(i, n) for(ll i = 0; i < n; i++) #define FOR(i,n,m) for(ll i = n; i <= m; i++) #define isIn(vec, item) find(vec.begin(), vec.end(), item) != vec.end() #define fs first #define sc second #define pb push_back #define mp make_pair #define all(v) v.begin(),v.end() #define inf 1000000005 #define mod 1000000007 #define print(v) for(auto e : v) cout << e << " "; cout << endl; ll a[200500]; ll segtree[400500]; int left(int i){return 2*i;} int right(int i){return 2*i+1;} int mid(int l, int r){return (l+r)/2;} int query(int i, int l, int r, int q){ if(q < l or r < q) return 0; if(l==r) return segtree[i]; int m = mid(l, r); return segtree[i] + query(left(i), l, m, q) + query(right(i), m+1, r, q); } void add(int i, int l, int r, int ql, int qr){ if(qr < l or r < ql) return; if(ql <= l and r <= qr){ segtree[i]++; return; } int m = mid(l, r); add(left(i), l, m, ql, qr); add(right(i), m+1, r, ql, qr); return; } ll count_swaps(vector<int> v){ map<int, queue<int>> m; int n = v.size(); int par[n]; memset(par, -1, sizeof par); loop(i, n){ int e = v[i]; if(m[-e].empty()){ m[e].push(i); }else{ par[m[-e].front()] = i; m[-e].pop(); } } ll ans = 0; loop(i, n){ if(par[i] == -1) continue; ans += par[i] - i - 1; if(v[i] > 0) ans++; ans += query(1, 1, n, i); ans -= query(1, 1, n, par[i]); printf("length %d | %d | %d\n", par[i] - i + 1, query(1, 1, n, i), query(1, 1, n, par[i])); add(1, 1, n, i+1, par[i]-1); } return ans; }

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

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:77:25: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
   77 |         printf("length %d |  %d | %d\n", par[i] - i + 1, query(1, 1, n, i), query(1, 1, n, par[i]));
      |                        ~^                ~~~~~~~~~~~~~~
      |                         |                           |
      |                         int                         ll {aka long long int}
      |                        %lld
#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...