답안 #63526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63526 2018-08-02T05:21:16 Z Talant Election (BOI18_election) C++17
28 / 100
3000 ms 1176 KB
#include <bits/stdc++.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)

using namespace std;

const int inf = (int)1e9 + 7;
const int N = (int)5e5 + 7;

int n;
int q;
int l,r;
int u[N];

string a;
vector <int> v;

main () {
      cin >> n;
      cin >> a;
      cin >> q;

      while (q --) {
            int sum = 0,sum1 = 0,f = 0;
            cin >> l >> r;

            l --,r --;

            for (int i = l; i <= r; i ++) {
                  if (a[i] == 'T' && f == 0) u[i] = 1;
                  else if (a[i] == 'T' && f > 0) f --;
                  else f ++;
            }
            f = 0;
            for (int i = r; i >= l; i --) {
                  if (u[i] == 1) continue;
                  if (a[i] == 'T' && f == 0) u[i] = 1;
                  else if (a[i] == 'T' && f > 0) f --;
                  else f ++;
            }
            for (int i = l; i <= r; i ++)
                  sum += u[i],u[i] = 0;

            v.pb(sum);
      }
      for (auto to : v)
            cout << to << endl;
}

Compilation message

election.cpp:25:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
election.cpp: In function 'int main()':
election.cpp:31:25: warning: unused variable 'sum1' [-Wunused-variable]
             int sum = 0,sum1 = 0,f = 0;
                         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 376 KB Output is correct
2 Correct 18 ms 488 KB Output is correct
3 Correct 16 ms 488 KB Output is correct
4 Correct 15 ms 488 KB Output is correct
5 Correct 10 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 376 KB Output is correct
2 Correct 18 ms 488 KB Output is correct
3 Correct 16 ms 488 KB Output is correct
4 Correct 15 ms 488 KB Output is correct
5 Correct 10 ms 488 KB Output is correct
6 Execution timed out 3046 ms 1176 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 376 KB Output is correct
2 Correct 18 ms 488 KB Output is correct
3 Correct 16 ms 488 KB Output is correct
4 Correct 15 ms 488 KB Output is correct
5 Correct 10 ms 488 KB Output is correct
6 Execution timed out 3046 ms 1176 KB Time limit exceeded
7 Halted 0 ms 0 KB -