QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#359959#407. ToiletsArapak20 1ms3572kbC++141.5kb2024-03-21 06:39:192024-03-21 06:39:20

Judging History

你现在查看的是最新测评结果

  • [2024-03-21 06:39:20]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3572kb
  • [2024-03-21 06:39:19]
  • 提交

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';
}

Details

Tip: Click on the bar to expand more detailed information

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%