Submission #87004

#TimeUsernameProblemLanguageResultExecution timeMemory
87004abilWeighting stones (IZhO11_stones)C++14
0 / 100
2 ms376 KiB
/** Solution by Abil **/ #include <bits/stdc++.h> using namespace std; vector<int > v1,v2; vector<int > :: iterator it; int fun(int qw){ int f = 0; if(v1.size() == v2.size()){ bool bl = true; for(int i = 0;i < v1.size(); i++){ if(v1[i] < v2[i]){ bl = false; break; } } if(bl){ f = 1; } bl = true; for(int i = 0;i < v1.size(); i++){ if(v1[i] > v2[i]){ bl = false; break; } } if(bl){ f = 2; } } else{ int cnt1 = 0,cnt2 = 0,in = 0; for(int i = 0;i < v1.size(); i++){ if(v1[i] > v2[in] && in < v2.size()){ cnt1++; in++; } } in = 0; for(int i = 0;i < v2.size(); i++){ if(v1[in] < v2[i] && in < v1.size()){ cnt2++; in++; } } if(cnt1 > cnt2){ f = 1; } if(cnt2 > cnt1){ f = 2; } } return f; } int main() { freopen("stones.in", "r", stdin); freopen("stones.out", "w", stdout); v1.push_back(0); v2.push_back(0); int n,ans1 = 0,ans2 = 0; cin >> n; int ves,dir; while(n--){ cin >> ves >> dir; if(dir == 1){ it = lower_bound(v1.begin(),v1.end(),ves); v1.insert(it,ves); } else{ it = lower_bound(v2.begin(),v2.end(),ves); v2.insert(it,ves); } int f = fun(1); if(f == 0){ cout << "?" << endl; } else if(f == 1){ cout << ">" << endl; } else{ cout << "<" << endl; } } }

Compilation message (stderr)

stones.cpp: In function 'int fun(int)':
stones.cpp:15:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < v1.size(); i++){
                   ~~^~~~~~~~~~~
stones.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < v1.size(); i++){
                   ~~^~~~~~~~~~~
stones.cpp:37:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < v1.size(); i++){
                   ~~^~~~~~~~~~~
stones.cpp:38:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(v1[i] > v2[in] && in < v2.size()){
                            ~~~^~~~~~~~~~~
stones.cpp:44:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < v2.size(); i++){
                   ~~^~~~~~~~~~~
stones.cpp:45:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(v1[in] < v2[i] && in < v1.size()){
                            ~~~^~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:65:11: warning: unused variable 'ans1' [-Wunused-variable]
     int n,ans1 = 0,ans2 = 0;
           ^~~~
stones.cpp:65:20: warning: unused variable 'ans2' [-Wunused-variable]
     int n,ans1 = 0,ans2 = 0;
                    ^~~~
stones.cpp:61:12: 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:62:12: 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);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...