i want u to act as the most skilled competetive programmer, u take time to think and…
- User
i want u to act as the most skilled competetive programmer, u take time to think and check if ur solution works and match up with the example tescase, u need to think thoroughly since u r in a contest. use need to use this template, make sure u have lowercase rlly short variable names and NO COMMENTS (in the code, at all) and since ur using this template always use int and not long long, PLS REVALUATE UR CODE AND MAKE SURE IT MAKES SURE IT MATCHES EVERY SINGLE SAMPLE INPUT AND OUTPUT GIVEN, THINK MULTIPLE TIMES BEFORE GIVING UR FINAL ANSWER AS THIS IS A CONTEST: #include <bits/stdc++.h> #define int long long using namespace std;
signed main() { cin.tie(0); ios_base::sync_with_stdio(false); }
Problem Description Thomas has N Nobjects and M Mbaskets in the room. Each object is represented by a capital letter of the alphabet, from TO TOto Z ZThe baskets are numbered by 0 0to M − 1 M−1. Each basket has an unlimited capacity and there is an order among the elements inside it: the element in position 0 0it's on the bottom, the one in position 1 1it is located immediately above, and so on.
"Some of Thomas's baskets"
Initially, all items are in order in the basket. 0 0, and their order is given by a string S Sin length N N. The first character of S Srepresents the object in position 0 0, and so on. However, when he is bored, Tom spends his time moving objects between baskets! In particular, he moves the object from the top of one basket to the top of another basket.
Help Thomas keep track of the objects in his room, always being ready to tell him which object is in a certain position in a certain basket, managing his Q Qmovements and questions.
Input data The first line of the input file contains an integer T T, the number of test cases. The following T Ttest cases, numbered by 1 1to T TEach test case is preceded by a blank line.
Each test case is composed as follows:
the first line contains the integers N N, M MAnd Q Q; the second line contains the string S S; the Q QThe next lines contain the description of a move or control: s to to b bindicates a move: the item on top of the basket to toit has been moved to the top of the bin b b(it is guaranteed that the basket to tocontains at least one object at the time of the move); c to to b bindicates a control: Thomas wants to know what the b b-th item from the bottom in the trash to to(it is guaranteed that the basket to tocontains at least b + 1 b+1objects at the time of inspection). Output data The output file should contain the answer to the test cases that you have solved. For each test case that you have solved, the output file should contain a line that says:
Case #t: ans ... where tis the test case number (starting from 1
- and ansis a string representing Thomas's responses to the controls. The the theThe -th character of the string is an uppercase letter that represents the answer to the the the-th check.
Hiring T
- Assistant
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { cin.tie(0); ios_base::sync_with_stdio(false); int T; cin>>T; for(int tc=1;tc<=T;tc++) { // Read blank lines string tmp; getline(cin,tmp); while(tmp.empty()) getline(cin,tmp); // Read N, M, Q int N,M,Q; string nmq; nmq = tmp; sscanf(nmq.c_str(),"%lld %lld %lld",&N,&M,&Q); // Read S string S; cin>>S; // Initialize baskets vector<vector<char>> bsk(M, vector<char>()); for(char c:S) bsk[0].push_back(c); // Process Q operations string ans=""; for(int i=0;i<Q;i++) { char type; cin>>type; if(type=='s') { int a,b; cin>>a>>b; char c = bsk[a].back(); bsk[a].pop_back(); bsk[b].push_back(c); } else { int b,a; cin>>b>>a; ans += bsk[a][b]; } } cout<<"Case #"<<tc<<": "<<ans<<"\n"; } }