Submission #882167

# Submission time Handle Problem Language Result Execution time Memory
882167 2023-12-02T18:07:39 Z Mr_Husanboy Weighting stones (IZhO11_stones) C++17
0 / 100
1000 ms 1056 KB
    #include <bits/stdc++.h>
    using namespace std;



    #ifdef LOCAL
    #include "debugger.cpp"
    #else
    #define debug(...)
    #endif
    template<class T>
    int len(T &a){
        return a.size();
    }

    using ll = long long;
    using pii = pair<int,int>;
    #define all(a) (a).begin(), (a).end()
    #define ff first
    #define ss second
    string fileio = "";


    mt19937 mt(time(nullptr));
    const int mod = 1e9 + 7;
    const int inf = 1e9;
    const ll infl = 1e18;
    const int maxn = 1e5 + 1;





    void solve(){
        int n; cin >> n;
        vector<int> lef, rig;
        for(int i = 0; i < n; i ++){
            int l, r; cin >> l >> r;
            if(r == 1){
                lef.push_back(l);
            }else{
                rig.push_back(l);
            }
            if(lef.empty()){
                cout << "<\n"; continue;
            }
            vector<int> cnt(2);
            sort(all(lef)); sort(all(rig));
            int sl = len(lef), sr = len(rig);
            while(sl && sr){
                sl --; sr --;
                cnt[rig[sr] > lef[sl]] ++;
            }
            debug(cnt);
            cout << (cnt[0] == 0 && sl == 0 ? "<" : cnt[1] == 0 && sr == 0 ? ">" : "?") << '\n';
        }
    }

    int main(){
        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        auto start = chrono::high_resolution_clock::now();
        #ifndef LOCAL
        if(fileio.size()){
            freopen((fileio + ".in").c_str(), "r", stdin);
            freopen((fileio + ".out").c_str(), "w", stdout);
        }
        #endif
        int testcases = 1;
        #ifdef Tests
        cin >> testcases;
        #endif
        while(testcases --){
            solve();
            cout << '\n';
            #ifdef LOCAL
            cout << "_________________________" << endl;
            #endif
        }
        #ifdef LOCAL
        auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start);
        
        cout << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl;
        #endif
        return 0;
    }

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:61:14: warning: variable 'start' set but not used [-Wunused-but-set-variable]
   61 |         auto start = chrono::high_resolution_clock::now();
      |              ^~~~~
stones.cpp:64:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |             freopen((fileio + ".in").c_str(), "r", stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:65:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |             freopen((fileio + ".out").c_str(), "w", stdout);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 6 ms 348 KB Output is correct
8 Correct 10 ms 492 KB Output is correct
9 Correct 8 ms 480 KB Output is correct
10 Correct 852 ms 608 KB Output is correct
11 Execution timed out 1048 ms 1056 KB Time limit exceeded
12 Halted 0 ms 0 KB -