답안 #82675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82675 2018-11-01T09:46:50 Z farukkastamonuda Take-out (POI13_usu) C++14
100 / 100
245 ms 39716 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000009
#define md 1000000007
#define li 1000005
#define mp make_pair
#define pb push_back
using namespace std;
int n,k,cev,bas1,bas2,c;
char s[li];
vector<int> v,p;
vector< vector<int> > ans;
int main(){
	scanf("%d %d",&n,&k);
	scanf("%s",s+1);
	p.pb(0);
	for(int i=1;i<=n;i++){
		v.pb(i);
		if(s[i]=='c'){
			c++;
			p.pb(0);
		}
		else p[c]++;
		if(c && p[c]+p[c-1]>=k){
			vector<int> T;
			for(int i=0;i<k+1;i++){
				T.pb(v.back());
				v.pop_back();
			}
			reverse(T.begin(),T.end());
			ans.pb(T);
			int X=p[c--];
			p.pop_back();
			p[c]-=k-X;
		}
	}
	for(int i=(int)ans.size()-1;i>=0;i--){
		for(int j=0;j<(int)ans[i].size();j++){
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Compilation message

usu.cpp: In function 'int main()':
usu.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
usu.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s+1);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 556 KB Output is correct
2 Correct 2 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 616 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 636 KB Output is correct
2 Correct 3 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2756 KB Output is correct
2 Correct 14 ms 2756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 4076 KB Output is correct
2 Correct 33 ms 4616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 7976 KB Output is correct
2 Correct 71 ms 7976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 11132 KB Output is correct
2 Correct 181 ms 12576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 245 ms 39716 KB Output is correct
2 Correct 129 ms 39716 KB Output is correct
3 Correct 116 ms 39716 KB Output is correct
4 Correct 124 ms 39716 KB Output is correct