답안 #1056982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056982 2024-08-13T12:48:44 Z kititnik Floppy (RMI20_floppy) C++14
100 / 100
454 ms 10416 KB
#include <bits/stdc++.h>
#include "floppy.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
 
void read_array(int sub, const vector<int> &v) {
	int n = v.size();
	stack<int> st;
	string s;
	for (int i = 0; i < n; i++) {
		while (st.size() && v[i] > v[st.top()]) {
			st.pop();
			s.push_back('0');
		}
		st.push(i);
		s.push_back('1');
	}
	save_to_floppy(s);
}
vector<int> solve_queries(int sub, int n, const string &bits, const vector<int> &a, const vector<int> &b) {
	int q = a.size();
	vector<array<int, 2>> ask[n];
	vector<int> ans(q, -1);
	for (int i = 0; i < q; i++) {
		ask[b[i]].push_back({a[i], i});
	}
// 	cout << "HI" << endl;
	vector<int> st;
	int cur = 0;
	for (int i = 0; i < n; i++) {
		while (bits[cur] == '0') {
			st.pop_back();
			cur++;
		}
		st.push_back(i);
// 		for (auto j : st) {
// 			cout << j << ' ';
// 		}
// 		cout << '\n';
		cur++;
		for (auto [l, idx] : ask[i]) {
			for (int j = st.size() - 1; j >= 0; j--) {
				if (j == 0 || st[j - 1] < l) {
					ans[idx] = st[j];
					break;
				}
			}
		}
	}
// 	for (auto i : ans) {
// 		cout << i << '\n';
// 	}
	return ans;
}

Compilation message

floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:44:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |   for (auto [l, idx] : ask[i]) {
      |             ^
stub.cpp: In function 'void run2()':
stub.cpp:101:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     if (query_answers.size() != M) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 804 KB Output is correct
2 Correct 1 ms 808 KB Output is correct
3 Correct 0 ms 812 KB Output is correct
4 Correct 0 ms 812 KB Output is correct
5 Correct 0 ms 804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2868 KB Output is correct
2 Correct 12 ms 2864 KB Output is correct
3 Correct 35 ms 3220 KB Output is correct
4 Correct 13 ms 3116 KB Output is correct
5 Correct 12 ms 2864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 10412 KB Output is correct
2 Correct 54 ms 10416 KB Output is correct
3 Correct 454 ms 10092 KB Output is correct
4 Correct 75 ms 10392 KB Output is correct
5 Correct 47 ms 10088 KB Output is correct