Submission #3926

#TimeUsernameProblemLanguageResultExecution timeMemory
3926zzapcoderJogging (kriii1_J)C++98
Compilation error
0 ms0 KiB
#include <cstdio> #include <cmath> #include <algorithm> #include <vector> using namespace std; class CRD{ public: CRD(int _x, int _y) : x(_x), y(_y) { } int x,y; }; std::vector<int> REST; std::vector<CRD> STAR; int N; int M; bool compare(CRD& A, CRD& B) { if ( A.x < B.x ) return true; else return false; } int main() { scanf("%d%d",&N,&M); for (int i = 0 ; i < N ; i++) { int tmpX, tmpY; scanf("%d%d", &tmpX, &tmpY); STAR.push_back( CRD(tmpX, tmpY) ); } std::sort(STAR.begin(), STAR.end(), compare); for ( int i = 0 ; i < M ; i++) { int tmpX; scanf("%d", &tmpX); REST.push_back(tmpX); } for ( int i = 0 ; i < M ; i ++) { int pos = REST[i]; std::vector<CRD> STARTMP; for ( int j = 0 ; j < N ; j++) { if ( pos < STAR[j].x ) STARTMP.push_back(STAR[j]); } if ( STARTMP.size() == 0 ) { printf("0.0000000\n"); continue; } double tmpMax = STARTMP[0].y/(STARTMP[0].x - (double)pos ); for ( int j = 1 ; j < STARTMP.size() ; j++) { if ( tmpMax < (STARTMP[j].y/(STARTMP[j].x - (double)pos)) ) tmpMax = (STARTMP[j].y/(STARTMP[j].x - (double)pos)); } // printf("pos: %d, tan : %.7lf\n", pos, tmpMax); double Result = atan(tmpMax); printf("%.7lf\n", Result); } return 0; }

Compilation message (stderr)

J.cpp: In function 'int main()':
J.cpp:64:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
In file included from /usr/include/c++/4.6/algorithm:63:0,
                 from J.cpp:3:
/usr/include/c++/4.6/bits/stl_algo.h: In function '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<CRD*, std::vector<CRD> >, _Tp = CRD, _Compare = bool (*)(CRD&, CRD&)]':
/usr/include/c++/4.6/bits/stl_algo.h:2265:78:   instantiated from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<CRD*, std::vector<CRD> >, _Compare = bool (*)(CRD&, CRD&)]'
/usr/include/c++/4.6/bits/stl_algo.h:2306:62:   instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<CRD*, std::vector<CRD> >, _Size = long int, _Compare = bool (*)(CRD&, CRD&)]'
/usr/include/c++/4.6/bits/stl_algo.h:5445:4:   instantiated from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<CRD*, std::vector<CRD> >, _Compare = bool (*)(CRD&, CRD&)]'
J.cpp:38:45:   instantiated from here
/usr/include/c++/4.6/bits/stl_algo.h:2233:4: error: invalid initialization of reference of type 'CRD&' from expression of type 'const CRD'
/usr/include/c++/4.6/bits/stl_algo.h:2236:4: error: invalid initialization of reference of type 'CRD&' from expression of type 'const CRD'
J.cpp: In function 'int main()':
J.cpp:29:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
J.cpp:34:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
J.cpp:44:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]