結果
| 問題 |
No.1292 パタパタ三角形
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-20 22:23:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 2,000 ms |
| コード長 | 1,758 bytes |
| コンパイル時間 | 831 ms |
| コンパイル使用メモリ | 90,608 KB |
| 実行使用メモリ | 16,128 KB |
| 最終ジャッジ日時 | 2024-07-23 13:18:53 |
| 合計ジャッジ時間 | 1,875 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>
using namespace std;
#define int long long
#define endl "\n"
constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;
struct fast_io {
fast_io(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
};
} fio;
signed main(){
cout<<fixed<<setprecision(10);
int x = 0, y = 0, z = 0;
set<pair<pair<int,int>,int>> S;
string s;
cin>>s;
S.insert({{x,y},z});
for(int i = 0; i < s.size(); i++){
int temp = ((y - x) % 3 + 3) % 3;
if(temp == 0) {
if(!z) {
if(s[i] == 'a') x--;
// if(s[i] == 'b') z++;
if(s[i] == 'c') y--;
} else {
if(s[i] == 'a') y++;
// if(s[i] == 'b') z--;
if(s[i] == 'c') x++;
}
} else if(temp == 1) {
if(!z) {
if(s[i] == 'b') x--;
// if(s[i] == 'c') z++;
if(s[i] == 'a') y--;
} else {
if(s[i] == 'b') y++;
// if(s[i] == 'c') z--;
if(s[i] == 'a') x++;
}
} else if(temp == 2) {
if(!z) {
if(s[i] == 'c') x--;
// if(s[i] == 'a') z++;
if(s[i] == 'b') y--;
} else {
if(s[i] == 'c') y++;
// if(s[i] == 'a') z--;
if(s[i] == 'b') x++;
}
}
z = !z;
S.insert({{x,y},z});
// cout<<x<<" "<<y<<" "<<z<<" "<<temp<<" "<<S.size()<<endl;
}
cout<<S.size()<<endl;
return 0;
}