제출 #305988

#제출 시각아이디문제언어결과실행 시간메모리
305988kylych03Arranging Shoes (IOI19_shoes)C++14
50 / 100
1089 ms14900 KiB
#include "shoes.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; long long res[200010]; int vis[200011], dp[200010]; vector <int> a[100002], b[100002]; long long count_swaps(std::vector<int> s) { long long sum = 0; for(int i = 0 ; i < s.size(); i++){ if(s[i]>0) a[s[i]].push_back(i); else b[abs(s[i])].push_back(i); } for(int i = 0 ; i <100001;i++){ for(int j = 0 ; j < a[i].size();j++){ dp[a[i][j]]=b[i][j]; dp[b[i][j]]=a[i][j]; } } for(int i = 0 ; i < s.size(); i++){ if(vis[i]==1) continue; int j=i+1; while( j!=dp[i] ){ res[j]++; j++; } sum += (j - i - 1 + (res[j] - res[i])); if(s[i] > 0) sum++; vis[dp[i]]=1; } return sum; }

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

shoes.cpp: In function 'long long int 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 < s.size(); i++){
      |                     ~~^~~~~~~~~~
shoes.cpp:19:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int j = 0 ; j < a[i].size();j++){
      |                         ~~^~~~~~~~~~~~~
shoes.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0 ; 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...