제출 #575408

#제출 시각아이디문제언어결과실행 시간메모리
575408webArranging Shoes (IOI19_shoes)C++17
0 / 100
19 ms2500 KiB
#include "shoes.h" #include <iostream> #include <vector> #include <tuple> #include <algorithm> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size()/2; // vector<pair<int, bool>>shoes(2*n); vector<int> posNegs; for(int i =0 ; i<2*n; ++i) { // shoes[i] = {abs(s[i]), s[i] < 0}; if(s[i] < 0) posNegs.push_back(i); } long long numSwaps = 0; /* //sort(shoes.begin(), shoes.end()); int currShoe = 0; while(currShoe < 2*n) { int findShoe = shoes[currShoe].first; int findShoeSign = !(shoes[currShoe].second); pair<int, bool> lastEl = {findShoe, findShoeSign}; for(int i = 1; i<(2*n-currShoe); ++i) { swap(lastEl, shoes[currShoe+ i]); if(lastEl.first == findShoe && lastEl.second == findShoeSign) { //found break; } numSwaps++; } if(shoes[currShoe].second == 0) { numSwaps++; swap(shoes[currShoe], shoes[currShoe+1]); } currShoe+=2; }*/ return (n*(n-1))/2; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:19:19: warning: unused variable 'numSwaps' [-Wunused-variable]
   19 |         long long numSwaps = 0;
      |                   ^~~~~~~~
#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...