Submission #28107

#TimeUsernameProblemLanguageResultExecution timeMemory
28107EyeOfSol (#71)The Ant and The Bitcoin (FXCUP2_ant)C++11
1 / 1
63 ms5208 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, l, t; ll mokx(ll a, ll b) { if (a>=0) return a/b; return (a-b+1)/b; } ll loc(ll a, ll dir, ll t) { ll v = a+t*dir; if (mokx(v,l)%2) return l-(v%l+l)%l; return (v%l+l)%l; } ll arr[100100], ord[100100]; vector<ll> vec; int main() { ll i; scanf("%lld%lld%lld",&n,&l,&t); for (i=0;i<n;i++) { char ch; ord[i] = i; scanf("%lld %c",&arr[i],&ch); if (ch=='L') vec.push_back(loc(arr[i],-1,t)); else vec.push_back(loc(arr[i],1,t)); } sort(ord,ord+n,[&](ll a, ll b){return arr[a]<arr[b];}); ll id; scanf("%lld",&id); id--; ll v = vec[id]; sort(vec.begin(),vec.end()); for (i=0;i<vec.size();i++) { if (vec[i]==v) { printf("%lld\n",ord[i]+1); break; } } return 0; }

Compilation message (stderr)

ant.cpp: In function 'int main()':
ant.cpp:37:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i=0;i<vec.size();i++) {
            ^
ant.cpp:24:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&n,&l,&t);
                                ^
ant.cpp:28:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %c",&arr[i],&ch);
                               ^
ant.cpp:34:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&id); id--;
                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...