結果
問題 | No.1292 パタパタ三角形 |
ユーザー | sapphire__15 |
提出日時 | 2020-11-20 22:20:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 2,912 bytes |
コンパイル時間 | 1,057 ms |
コンパイル使用メモリ | 120,236 KB |
実行使用メモリ | 15,960 KB |
最終ジャッジ日時 | 2023-09-30 19:29:48 |
合計ジャッジ時間 | 2,203 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 31 ms
6,048 KB |
testcase_08 | AC | 30 ms
5,816 KB |
testcase_09 | AC | 64 ms
15,420 KB |
testcase_10 | AC | 66 ms
15,248 KB |
testcase_11 | AC | 64 ms
15,260 KB |
testcase_12 | AC | 69 ms
15,892 KB |
testcase_13 | AC | 83 ms
15,960 KB |
testcase_14 | AC | 8 ms
4,380 KB |
testcase_15 | AC | 7 ms
4,376 KB |
testcase_16 | AC | 7 ms
4,380 KB |
ソースコード
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <cassert> #include <stack> typedef long long ll; typedef std::pair<int, int> Pii; typedef std::pair<long long, long long> Pll; typedef std::pair<double, double> Pdd; #define rip(i, n, ss) for (int i = (ss);i < (int)( n ); i++) #define all(l) l.begin(), l.end() #define MM << " " << template<typename T> using MaxHeap = std::priority_queue<T>; template<typename T> using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>; template<typename T> inline bool chmax(T &l, const T b) { if (l < b) { l = b; return true; } return false; } template<typename T> inline bool chmin(T &l, const T b) { if (l > b) { l = b; return true; } return false; } # ifdef LOCAL_DEBUG template<typename T> void vdeb(const std::vector<T> &bb) { for (unsigned int i = 0;i < bb.size();i++) { if (i == bb.size() - 1) std::cout << bb[i]; else std::cout << bb[i] << ' '; } std::cout << '\n'; } template<typename T> void vdeb(const std::vector<std::vector<T>> &bb) { for (unsigned int i = 0;i < bb.size();i++) { std::cout << i << ' '; vdeb(bb[i]); } std::cout << '\n'; } # endif using namespace std; struct Tri{ Pii cent; int num; void move(char c) { if(c == 'b') { if(num&1) { num++; if(num == 6) num = 0; } else { num--; if(num == -1) num += 6; } } else if(c == 'c') { if(num&1) { num--; if(num == -1) num += 6; } else { num++; if(num == 6) num = 0; } } else if(c == 'a') { if(num == 0) { cent.first++; } else if(num == 1) { cent.second++; } else if(num == 2) { cent.first--; cent.second++; } else if(num == 3) { cent.first--; } else if(num == 4) { cent.second--; } else if(num == 5) { cent.first++; cent.second--; } num += 3; if(num >= 6) { num %= 6; } } } }; bool operator<(const Tri &x, const Tri &y) { if(x.num == y.num) return x.cent < y.cent; else return x.num < y.num; } int main() { string s; cin >> s; Tri x = {{0, 0}, 0}; set<Tri> st; st.insert(x); for(auto i: s) { x.move(i); st.insert(x); } cout << st.size() << endl; }