답안 #471162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471162 2021-09-07T15:04:08 Z mosiashvililuka Floppy (RMI20_floppy) C++14
100 / 100
120 ms 12684 KB
#include<bits/stdc++.h>
#include "floppy.h"
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[200009],pi,lef,rig,mid;
pair <pair <int, int>, int> p[200009];
vector <int> ans;
deque <int> de;
string s;
void read_array(int subtask_id, const std::vector<int> &v) {
	a=v.size();
    for(i=1; i<=a; i++){
    	f[i]=v[i-1];
	}
	while(de.size()) de.pop_back();
	for(i=1; i<=a; i++){
		while(de.size()&&f[de.back()]<f[i]){
			de.pop_back();s+="1";
		}
		de.push_back(i);s+="0";
	}
	//cout<<s<<endl;
    save_to_floppy(s);
}

vector<int> solve_queries(int subtask_id, int N,
        const std::string &bits,
        const std::vector<int> &A, const std::vector<int> &B) {
    
    while(de.size()) de.pop_back();
	a=N;ans.resize(A.size());
    for(i=0; i<A.size(); i++){
    	pi++;p[pi].first.second=A[i]+1;p[pi].first.first=B[i]+1;p[pi].second=i;
	}
	sort(p+1,p+pi+1);
	for(i=1; i<=pi; i++) swap(p[i].first.first,p[i].first.second);
	j=0;ii=1;
	for(i=1; i<=pi; i++){
		for(jj=ii; jj<=p[i].first.second; jj++){
			while(1){
				if(bits[j]=='0') break;
				de.pop_back();
				j++;
			}
			de.push_back(jj);j++;
		}
		ii=jj;
		lef=-1;rig=de.size();
		while(1){
			if(lef+1>=rig) break;
			mid=(lef+rig)/2;
			if(de[mid]>=p[i].first.first){
				rig=mid;
			}else{
				lef=mid;
			}
		}
		//cout<<de.size()<<" "<<rig<<endl;
		ans[p[i].second]=de[rig]-1;
	}
	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:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(i=0; i<A.size(); 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 2 ms 780 KB Output is correct
2 Correct 2 ms 780 KB Output is correct
3 Correct 2 ms 780 KB Output is correct
4 Correct 3 ms 744 KB Output is correct
5 Correct 2 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 3540 KB Output is correct
2 Correct 27 ms 3460 KB Output is correct
3 Correct 29 ms 3448 KB Output is correct
4 Correct 29 ms 3480 KB Output is correct
5 Correct 27 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 12576 KB Output is correct
2 Correct 120 ms 12636 KB Output is correct
3 Correct 114 ms 12592 KB Output is correct
4 Correct 112 ms 12684 KB Output is correct
5 Correct 109 ms 12576 KB Output is correct