제출 #824470

#제출 시각아이디문제언어결과실행 시간메모리
824470caganyanmazArranging Shoes (IOI19_shoes)C++17
10 / 100
2 ms596 KiB
#include <bits/stdc++.h> #define mp(x...) array<int, 2>({x}) #define pb push_back #define int int64_t #define vi vector<int32_t> using namespace std; #include "shoes.h" constexpr static int MXSIZE = 1e6; struct Fenwick { int v[MXSIZE]; void set(int i, int val) { for (++i;i<MXSIZE;i+=i&(-i)) v[i] += val; } int get(int i) { int res = 0; for(++i;i>0;i-=i&(-i)) res += v[i]; return res; } }; int subtask1(vi& s) { if (s[0] > 0) return 1; else return 0; } Fenwick fw; int last[MXSIZE]; map<int, int> pos; int subtask4(vi& s) { int n = s.size() / 2; for (int i = 0; i < n; i++) { int p = (-s[i]) * (n+1) + last[s[i]]++; pos[p] = i; // Leftover in the left } for (int i = 1; i <= n; i++) last[i] = 0; int res = 0; for (int i = n; i < s.size(); i++) { int p = s[i] * (n+1) + last[s[i]]++; assert(pos.find(p) != pos.end()); int ps = pos[p]; res += i-ps-1 - fw.get(ps); fw.set(ps, 1); last[s[i]]++; } return res; } long long count_swaps(vi s) { if (s.size() == 2) return subtask1(s); return subtask4(s); }

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

shoes.cpp: In function 'int64_t subtask4(std::vector<int>&)':
shoes.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for (int i = n; i < s.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...
#Verdict Execution timeMemoryGrader output
Fetching results...