QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#359959 | #407. Toilets | Arapak2 | 0 | 1ms | 3572kb | C++14 | 1.5kb | 2024-03-21 06:39:19 | 2024-03-21 06:39:20 |
answer
// Author: Kajetan Ramsza
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename F, typename S> ostream& operator<<(ostream& os, const pair<F, S> &p) { return os<<"("<<p.first<<", "<<p.second<<")"; }
template<typename T> ostream &operator<<(ostream & os, const vector<T> &v) { os << "{"; typename vector< T > :: const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) { if( it != v.begin() ) os << ", "; os << *it; } return os << "}"; }
void dbg_out() { cerr<<'\n'; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr<<' '<<H; dbg_out(T...); }
#ifdef DEBUG
#define dbg(...) cerr<<"(" << #__VA_ARGS__ <<"):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
ll n;
int m;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
ll sum = 0;
ll maxi = 0;
ll ind = 0;
rep(o,0,m) {
string s; ll k;
cin>>s>>k;
ll curr = 0;
rep(i,0,sz(s)) {
curr += s[i] == 'F' ? +1 : -1;
if((ind + ll(i)) & 1) maxi = max(maxi, sum + curr);
}
sum += curr * (k-1);
ind += ll(sz(s)) * (k-1);
rep(i,0,sz(s)) {
sum += s[i] == 'F' ? +1 : -1;
if((ind + ll(i)) & 1) maxi = max(maxi, sum);
}
ind += ll(sz(s));
}
dbg(sum, maxi);
if(sum < 0) cout<<-1<<'\n';
else cout<<maxi - sum<<'\n';
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3572kb
input:
10 1 FMFFFFFFMFFFMMMMMFMM 1
output:
6
result:
wrong answer 1st lines differ - expected: '5', found: '6'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%