Submission #87037

#TimeUsernameProblemLanguageResultExecution timeMemory
87037rakutenWeighting stones (IZhO11_stones)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; int x , a , n , x1 , x2; set < int > v ; set < int > :: iterator vi ; set < int > q ; set < int > :: iterator qi ; int main() { freopen ("stones.in" , "r" , stdin) ; freopen ("stones.out" , "w" , stdout) ; scanf ("%d" , &n) ; for (int i = 0 ;i < n ;i ++ ) { x1 = 0 ; x2 = 0 ; scanf ("%d%d" , &x , &a) ; if (i == 0) { if (a == 1) cout << '>' << endl ; else cout << '<' << endl ; if (a == 1) v.insert (x) ; else q.insert (x) ; } else { if (a == 1) v.insert (x) ; else q.insert (x) ; if (v.size() == 0) cout << '<' << endl ; else if (q.size() == 0 ) cout << '>' << endl ; else { qi = -- q.end(); for (vi = --v.end(); vi != v.begin() ; vi -- ) { if ( (*vi) > (*qi)) x1 ++ ; else x2 ++ ; if (qi == q.begin() || (x1 > 0 && x2 > 0) ) break; qi -- ; } if (x1 > x2 && x2 == 0 && x1 == q.size()) cout << '>' << endl ; else if (x1 < x2 && x1 == 0 && x2 == v.size()) cout << '<' << endl; else cout << '?' << endl ; } } } }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:57:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (x1 > x2 && x2 == 0 && x1 == q.size())
                                           ~~~^~~~~~~~~~~
stones.cpp:60:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (x1 < x2 && x1 == 0 && x2 == v.size())
                                           ~~~^~~~~~~~~~~
stones.cpp:12:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
      freopen ("stones.in" , "r" , stdin) ;
      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:13:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
      freopen ("stones.out" , "w" , stdout) ;
      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:14:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf ("%d" , &n) ;
      ~~~~~~^~~~~~~~~~~
stones.cpp:19:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
          scanf ("%d%d" , &x , &a) ;
          ~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...