# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
634937 | 2022-08-25T09:11:30 Z | danikoynov | Floppy (RMI20_floppy) | C++14 | 457 ms | 15164 KB |
#include<bits/stdc++.h> #include "floppy.h" using namespace std; const int maxn = 40010; void save_to_floppy(const string &); void read_array(int subtask_id, vector < int > const&v) { stack < int > st; st.push(0); string bit = ""; for (int i = 1; i < v.size(); i ++) { while(!st.empty() && v[st.top()] < v[i]) { bit = bit + "0"; st.pop(); } st.push(i); bit = bit + "1"; } save_to_floppy(bit); } vector < pair < int, int > > g[maxn]; int par[maxn]; int find_leader(int v) { if (v == par[v]) return v; return find_leader(par[v]); } void unite(int v, int u) { v = find_leader(v); u = find_leader(u); if (v < u) swap(v, u); par[u] = v; } vector < int > ans; vector < int > solve_queries(int subtask_id, int N, const string &bits, const vector < int > &a, const vector < int > &b) { for (int i = 0; i < N; i ++) par[i] = i; int m = a.size(); ans.resize(m); for (int i = 0; i < m; i ++) { g[b[i]].push_back({a[i], i}); } stack < int > st; st.push(0); int idx = 0; for (pair < int, int > p : g[0]) { ans[p.second] = find_leader(p.first); } for (int i = 1; i < N; i ++) { while(bits[idx] != '1') { unite(st.top(), i); st.pop(); idx ++; } st.push(i); idx ++; for (pair < int, int > p : g[i]) { ans[p.second] = find_leader(p.first); ///cout << p.second << " : " << find_leader(p.first) << " " << p.first << " " << i << endl; } } /**for (int i = 0; i < m; i ++) cout << ans[i] << " "; cout << endl;*/ return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2732 KB | Output is correct |
2 | Correct | 3 ms | 2724 KB | Output is correct |
3 | Correct | 2 ms | 2732 KB | Output is correct |
4 | Correct | 3 ms | 2724 KB | Output is correct |
5 | Correct | 4 ms | 2612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 5644 KB | Output is correct |
2 | Correct | 36 ms | 5548 KB | Output is correct |
3 | Correct | 27 ms | 5544 KB | Output is correct |
4 | Correct | 39 ms | 5580 KB | Output is correct |
5 | Correct | 35 ms | 5660 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 365 ms | 15140 KB | Output is correct |
2 | Correct | 398 ms | 15072 KB | Output is correct |
3 | Correct | 182 ms | 15040 KB | Output is correct |
4 | Correct | 457 ms | 15092 KB | Output is correct |
5 | Correct | 379 ms | 15164 KB | Output is correct |