제출 #641842

#제출 시각아이디문제언어결과실행 시간메모리
641842knon0501Finding Routers (IOI20_routers)C++14
0 / 100
2 ms468 KiB
#include "routers.h" #include <bits/stdc++.h>; using namespace std; const int B=400; int c[1005]; int b[200005]; std::vector<int> find_routers(int l, int n, int q) { vector<int> ans={0}; // cout<<l<<" "<<n<<" "<<q<<endl; int j=1; int prv=0; for(int i=B ; i<=l ; i+=B){ int x=use_detector(i); for( ; j<x ; j++){ int lef=prv+1; int rig=i-1; while(rig-lef>=4*B){ lef+=B; rig-=B; } int k; while(rig>=lef){ int mid=lef+rig>>1; int y=use_detector(mid); if(y<j){ k=mid; lef=mid+1; } else{ rig=mid-1; } } ans.push_back(2*k-ans[j-1]); prv=k; } } for (; j <n; j++) { int lef = prv + 1; int rig = l; while (rig - lef >= 4 * B) { lef += B; rig -= B; } int k; while (rig >= lef) { int mid = lef + rig >> 1; int y = use_detector(mid); if (y < j) { k = mid; lef = mid + 1; } else { rig = mid - 1; } } ans.push_back(2 * k - ans[j - 1]); prv = k; } return ans; }

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

routers.cpp:2:25: warning: extra tokens at end of #include directive
    2 | #include <bits/stdc++.h>;
      |                         ^
routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:24:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |                 int mid=lef+rig>>1;
      |                         ~~~^~~~
routers.cpp:50:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |             int mid = lef + rig >> 1;
      |                       ~~~~^~~~~
routers.cpp:62:25: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |         ans.push_back(2 * k - ans[j - 1]);
      |                       ~~^~~
routers.cpp:34:28: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |             ans.push_back(2*k-ans[j-1]);
      |                           ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...