Submission #298195

#TimeUsernameProblemLanguageResultExecution timeMemory
298195arayiArranging Shoes (IOI19_shoes)C++17
10 / 100
116 ms134960 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 30; stack <int> a[N]; long long pat; int v(int x) { if(x < 0) return -1; else return 1; } long long count_swaps(std::vector<int> s) { for (int i = 1; i <= s.size(); i++) { int x = abs(s[i - 1]); if(a[x].empty() || v(s[i - 1]) == v(a[x].top())) a[x].push(i * v(s[i - 1])); else { pat += i - abs(a[x].top()); a[x].pop(); if(s[i - 1] > 0) pat--; } } return pat; }

Compilation message (stderr)

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