Submission #609709

#TimeUsernameProblemLanguageResultExecution timeMemory
609709strange420Roller Coaster Railroad (IOI16_railroad)C++14
0 / 100
444 ms28420 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define MAXN 500000 int fenwick[MAXN], n; void fenwickPointUpdate(int i, int val) { i++; while (i <= n) { fenwick[i] += val; i += i & (-i); } } void fenwickUpdate(int l, int r) { fenwickPointUpdate(l, 1); fenwickPointUpdate(r, -1); } int getSum(int x) { int sum = 0; while (x > 0) { sum += fenwick[x]; x -= x & (-x); } return sum; } int fenwickQuery(int x) { x--; return getSum(x) - getSum(x-1); } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { n = (int) s.size(); vector<int> asd; for (int x: s) asd.push_back(x); for (int x: t) asd.push_back(x); sort(asd.begin(), asd.end()); map<int,int> indexing; for (int i=0; i<asd.size(); i++) indexing[asd[i]] = i; for (int i=0; i<n; i++) { s[i] = indexing[s[i]]; t[i] = indexing[t[i]]; } for (int i=0; i<n; i++) fenwickUpdate(s[i], t[i] + 1); for (int i=0; i<2*n; i++) if (fenwickQuery(i) > 0) return 1; return 0; }

Compilation message (stderr)

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