제출 #28092

#제출 시각아이디문제언어결과실행 시간메모리
28092EyeOfSol (#71)개미와 비트코인 (FXCUP2_ant)C++11
1 / 1
59 ms3656 KiB
#include <bits/stdc++.h> using namespace std; int n, l, t; int mokx(int a, int b) { if (a>=0) return a/b; return (a-b+1)/b; } int loc(int a, int dir, int t) { int v = a*dir+t; if (mokx(v,l)%2) return l-(v%l+l)%l; return (v%l+l)%l; } int arr[100100], ord[100100]; vector<int> vec; int main() { int i; scanf("%d%d%d",&n,&l,&t); for (i=0;i<n;i++) { char ch; ord[i] = i; scanf("%d %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,[](int a, int b){return arr[a]<arr[b];}); int id; scanf("%d",&id); id--; int v = vec[id]; sort(vec.begin(),vec.end()); for (i=0;i<vec.size();i++) { if (vec[i]==v) printf("%d\n",ord[i]+1); } return 0; }

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

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