Submission #771250

#TimeUsernameProblemLanguageResultExecution timeMemory
771250teamariaaArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms304 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; long long count_swaps(vector<int> s) { long long n = s.size() / 2; if(n == 1) if(s[0] < s[1]) return 0; else return 1; bool ok = 0; for(int i = 1; i < s.size() && !ok; i ++) if(abs(s[i]) != abs(s[i - 1])) ok = 1; if(!ok) { int pos = 0; long long ans = 0; for(int i = 0; i < s.size(); i ++) if(s[i] < 0) { ans += i - pos; pos += 2; } return ans; } return n * (n - 1) / 2; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:9:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
    9 |     if(n == 1)
      |       ^
shoes.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 1; i < s.size()  &&  !ok; i ++)
      |                    ~~^~~~~~~~~~
shoes.cpp:24:26: 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...