結果
| 問題 |
No.457 (^^*)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-08 00:30:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,815 bytes |
| コンパイル時間 | 735 ms |
| コンパイル使用メモリ | 80,656 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 04:27:18 |
| 合計ジャッジ時間 | 1,429 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:32:38: warning: NULL used in arithmetic [-Wpointer-arith]
32 | for (int i = 1; letter[i] != NULL; i++) {
| ^~~~
ソースコード
#include "iostream"
#include "time.h"
#include "stdlib.h"
#include "iomanip"
#include "math.h"
#include "algorithm"
#include "functional"
using namespace std;
char letter[20000];
int ast[10000];
int l_ast[10000];
int r_ast[10000];
int l_face[10000];
int r_face[10000];
int eye[10000];
int l_eye[10000];
int r_eye[10000];
int num;
int box;
int bag;
int l_ans;
int r_ans;
int main() {
cin >> letter;
if (letter[0] == '^')eye[0] ++;
if (letter[0] == '(')l_face[0]++;
if (letter[0] == ')')r_face[0]++;
if (letter[0] == '*')ast[0]++;
for (int i = 1; letter[i] != NULL; i++) {
eye[i] = eye[i - 1];
l_face[i] = l_face[i - 1];
r_face[i] = r_face[i - 1];
ast[i] = ast[i - 1];
if (letter[i] == '^')eye[i] ++;
if (letter[i] == '(')l_face[i]++;
if (letter[i] == ')')r_face[i]++;
if (letter[i] == '*')ast[i]++;
num=i;
}
box = -1;
for (int i = 0; i <= num; i++) {
if (letter[i] == '*')box = i;
l_ast[i] = box;
}
box = -1;
for (int i = num; i >= 0; i--) {
if (letter[i] == '*')box = i;
r_ast[i] = box;
}
box = -1;
bag = -1;
for (int i = 0; i <= num; i++) {
if (letter[i] == '^') {
bag = box;
box = i;
}
l_eye[i]=bag;
}
box = -1;
bag = -1;
for (int i = num; i >= 0; i--) {
if (letter[i] == '^') {
bag = box;
box = i;
}
r_eye[i]=bag;
}
for (int i = 0; i <= num; i++) {
if (letter[i] == '(') {
if (r_ast[i] != -1) {
if (r_eye[r_ast[i]] != -1) {
r_ans += r_face[num] - r_face[r_eye[r_ast[i]]];
}
}
}
}
for (int i = num; i >= 0; i--) {
if (letter[i] == ')') {
if (l_ast[i] != -1) {
if (l_eye[l_ast[i]] != -1) {
l_ans += l_face[l_eye[l_ast[i]]];
}
}
}
}
/*for (int i = 0; i <= num; i++) {
cout << l_ast[i] << r_ast[i] << l_eye[i] << r_eye[i] << endl;
}*/
cout << l_ans << " " << r_ans << "\n";
return 0;
}