結果
| 問題 |
No.1292 パタパタ三角形
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2020-05-22 19:55:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 2,267 bytes |
| コンパイル時間 | 1,658 ms |
| コンパイル使用メモリ | 173,620 KB |
| 実行使用メモリ | 13,040 KB |
| 最終ジャッジ日時 | 2024-07-04 18:31:11 |
| 合計ジャッジ時間 | 2,695 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;
set<pair<int, int>> pos;
int x = 0;
int y = 0;
pos.insert(make_pair(x, y));
int N = S.size();
assert(N >= 1);
assert(N <= 200000);
for (int i = 0; i < N; i++){
int X = x % 6;
if (X < 0){
X += 6;
}
int Y = y % 2;
if (Y < 0){
Y += 2;
}
assert(S[i] == 'a' || S[i] == 'b' || S[i] == 'c');
if (S[i] == 'a'){
if (Y == 0){
if (X == 0){
x++;
} else if (X == 1){
x--;
} else if (X == 2){
y--;
} else if (X == 3){
x++;
} else if (X == 4){
x--;
} else if (X == 5){
y++;
}
} else {
if (X == 0){
x++;
} else if (X == 1){
x--;
} else if (X == 2){
y++;
} else if (X == 3){
x++;
} else if (X == 4){
x--;
} else if (X == 5){
y--;
}
}
}
if (S[i] == 'b'){
if (Y == 0){
if (X == 0){
y--;
} else if (X == 1){
x++;
} else if (X == 2){
x--;
} else if (X == 3){
y++;
} else if (X == 4){
x++;
} else if (X == 5){
x--;
}
} else {
if (X == 0){
y++;
} else if (X == 1){
x++;
} else if (X == 2){
x--;
} else if (X == 3){
y--;
} else if (X == 4){
x++;
} else if (X == 5){
x--;
}
}
}
if (S[i] == 'c'){
if (Y == 0){
if (X == 0){
x--;
} else if (X == 1){
y++;
} else if (X == 2){
x++;
} else if (X == 3){
x--;
} else if (X == 4){
y--;
} else if (X == 5){
x++;
}
} else {
if (X == 0){
x--;
} else if (X == 1){
y--;
} else if (X == 2){
x++;
} else if (X == 3){
x--;
} else if (X == 4){
y++;
} else if (X == 5){
x++;
}
}
}
pos.insert(make_pair(x, y));
}
cout << pos.size() << endl;
}
SSRS