D. Challenges in school №41 模拟

Posted jrjxt

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了D. Challenges in school №41 模拟相关的知识,希望对你有一定的参考价值。

题目链接

解题思路:判断形成目标状态所须的最小,最大时间,与标准时间对比,在其区间内,则可行,然后模拟

 1 #include<bits/sdtc++.h>
 2 using namespace std;
 3 #define ll long long 
 4 int n, k;
 5 ll maxk = 0ll, mink = 0ll, d;
 6 char str[3050];
 7 vector<int> v[300050];
 8 void solve()
 9 {
10     int p = 0, p2 = 0, kk = mink;
11     while(kk<k){
12         cout << "1 " << v[p][p2] << endl;
13         p2++;
14         if(p2==v[p].size()){
15             p2=0;
16             p++;
17         }
18         else kk++;
19     }
20     cout << v[p].size() - p2;
21     for(int i = p2; i < v[p].size(); i++)
22         cout << " " << v[p][i];
23     cout << endl;
24     while(p<mink){
25         cout << v[p].size();
26         for(int i = 0; i < v[p].size(); i++)
27             cout << " " << v[p][i];
28         cout << endl;
29         p++;
30     }
31 }
32 void check(int p){
33     for(int i = 1; i < n; ){
34         if(str[i] == R && str[i+1] == L){
35             str[i] = L;
36             str[i+1] = R;
37             v[p].push_back(i);
38             i += 2;
39         }
40         else i++;
41     }
42 }
43 int main()
44 {
45     ios::sync_with_stdio(false);
46     cin.tie(0); cout.tie(0);
47     cin >> n >> k >> (str+1);
48     check(0);
49     while(v[mink].size()&&mink<=k){
50         maxk += v[mink].size();
51         mink++;
52         check(mink);
53     }
54     if(mink<=k&&k<=maxk) solve();
55     else cout << -1 << endl;
56 }

 

以上是关于D. Challenges in school №41 模拟的主要内容,如果未能解决你的问题,请参考以下文章

codeforces-1333D-Challenges in school №41

D. Anton and School - 2 范德蒙恒等式

codeforces 785D D. Anton and School - 2

CF #404 (Div. 2) D. Anton and School - 2 (数论+范德蒙恒等式)

Challenges and Open Problems in Signal Processing: Panel Discussion Summary from ICASSP 2017

Xamarin.Forms Layout Challenges – Social Network App(转载)