제출 #1030710

#제출 시각아이디문제언어결과실행 시간메모리
1030710ZicrusArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms432 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; typedef long long ll; ll count_swaps(vector<int> a) { ll n = a.size() / 2; vector<vector<ll>> seenQNeg(n+10); vector<vector<ll>> seenQPos(n+10); ll res = 0; for (int i = 0; i < a.size(); i++) { auto &q = a[i] < 0 ? seenQNeg[-a[i]] : seenQPos[a[i]]; auto &pairQ = a[i] > 0 ? seenQNeg[a[i]] : seenQPos[-a[i]]; if (pairQ.empty()) { q.insert(q.begin(), i); } else { ll id = pairQ.back(); pairQ.pop_back(); if (a[i] < 0) { res += abs(id - i); } else { res += abs(id - i) - 1; } } } return res; }

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

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < a.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...