結果
問題 | No.1292 パタパタ三角形 |
ユーザー | commy |
提出日時 | 2020-11-28 19:37:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 4,706 bytes |
コンパイル時間 | 1,734 ms |
コンパイル使用メモリ | 130,052 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2024-09-12 23:28:56 |
合計ジャッジ時間 | 2,987 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 33 ms
6,940 KB |
testcase_08 | AC | 33 ms
6,940 KB |
testcase_09 | AC | 58 ms
12,400 KB |
testcase_10 | AC | 63 ms
12,416 KB |
testcase_11 | AC | 59 ms
12,236 KB |
testcase_12 | AC | 63 ms
12,928 KB |
testcase_13 | AC | 58 ms
13,056 KB |
testcase_14 | AC | 10 ms
6,940 KB |
testcase_15 | AC | 10 ms
6,940 KB |
testcase_16 | AC | 11 ms
6,944 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <numeric> #include <utility> #include <tuple> #define rep(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; using ll = long long int; using P = pair<int, int>; // clang-format off #ifdef _DEBUG_ #define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false) template<typename T> void PPPPP(T t) { cerr << t; } template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); } #else #define dump(...) do{ } while(false) #endif template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); } template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; } template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; } template<typename T> void print(T a) { cout << a << '\n'; } template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); } template<typename T> istream &operator,(istream &in, T &t) { return in >> t; } // clang-format on #include <map> #include <set> using T = tuple<int, int, int, int>; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); string s; cin, s; map<T, map<int, T>> nxt; map<T, map<int, P>> dk; // right, down, left, up nxt[T(0, 1, 2, 3)][0] = T(1, 3, 0, 2); nxt[T(0, 1, 2, 3)][1] = T(0, 3, 2, 1); nxt[T(0, 1, 2, 3)][2] = T(2, 3, 1, 0); nxt[T(0, 2, 1, 3)][0] = T(2, 3, 0, 1); nxt[T(0, 2, 1, 3)][1] = T(1, 3, 2, 0); nxt[T(0, 2, 1, 3)][2] = T(0, 3, 1, 2); nxt[T(1, 0, 2, 3)][0] = T(1, 3, 2, 0); nxt[T(1, 0, 2, 3)][1] = T(0, 3, 1, 2); nxt[T(1, 0, 2, 3)][2] = T(2, 3, 0, 1); nxt[T(1, 2, 0, 3)][0] = T(0, 3, 2, 1); nxt[T(1, 2, 0, 3)][1] = T(2, 3, 1, 0); nxt[T(1, 2, 0, 3)][2] = T(1, 3, 0, 2); nxt[T(2, 0, 1, 3)][0] = T(2, 3, 1, 0); nxt[T(2, 0, 1, 3)][1] = T(1, 3, 0, 2); nxt[T(2, 0, 1, 3)][2] = T(0, 3, 2, 1); nxt[T(2, 1, 0, 3)][0] = T(0, 3, 1, 2); nxt[T(2, 1, 0, 3)][1] = T(2, 3, 0, 1); nxt[T(2, 1, 0, 3)][2] = T(1, 3, 2, 0); nxt[T(0, 3, 1, 2)][0] = T(2, 1, 0, 3); nxt[T(0, 3, 1, 2)][1] = T(1, 0, 2, 3); nxt[T(0, 3, 1, 2)][2] = T(0, 2, 1, 3); nxt[T(0, 3, 2, 1)][0] = T(1, 2, 0, 3); nxt[T(0, 3, 2, 1)][1] = T(0, 1, 2, 3); nxt[T(0, 3, 2, 1)][2] = T(2, 0, 1, 3); nxt[T(1, 3, 0, 2)][0] = T(0, 1, 2, 3); nxt[T(1, 3, 0, 2)][1] = T(2, 0, 1, 3); nxt[T(1, 3, 0, 2)][2] = T(1, 2, 0, 3); nxt[T(1, 3, 2, 0)][0] = T(1, 0, 2, 3); nxt[T(1, 3, 2, 0)][1] = T(0, 2, 1, 3); nxt[T(1, 3, 2, 0)][2] = T(2, 1, 0, 3); nxt[T(2, 3, 0, 1)][0] = T(0, 2, 1, 3); nxt[T(2, 3, 0, 1)][1] = T(2, 1, 0, 3); nxt[T(2, 3, 0, 1)][2] = T(1, 0, 2, 3); nxt[T(2, 3, 1, 0)][0] = T(2, 0, 1, 3); nxt[T(2, 3, 1, 0)][1] = T(1, 2, 0, 3); nxt[T(2, 3, 1, 0)][2] = T(0, 1, 2, 3); dk[T(0, 1, 2, 3)][0] = P(1, 0); dk[T(0, 1, 2, 3)][1] = P(0, -1); dk[T(0, 1, 2, 3)][2] = P(-1, 0); dk[T(0, 2, 1, 3)][0] = P(1, 0); dk[T(0, 2, 1, 3)][1] = P(-1, 0); dk[T(0, 2, 1, 3)][2] = P(0, -1); dk[T(1, 0, 2, 3)][0] = P(0, -1); dk[T(1, 0, 2, 3)][1] = P(1, 0); dk[T(1, 0, 2, 3)][2] = P(-1, 0); dk[T(1, 2, 0, 3)][0] = P(-1, 0); dk[T(1, 2, 0, 3)][1] = P(1, 0); dk[T(1, 2, 0, 3)][2] = P(0, -1); dk[T(2, 0, 1, 3)][0] = P(0, -1); dk[T(2, 0, 1, 3)][1] = P(-1, 0); dk[T(2, 0, 1, 3)][2] = P(1, 0); dk[T(2, 1, 0, 3)][0] = P(-1, 0); dk[T(2, 1, 0, 3)][1] = P(0, -1); dk[T(2, 1, 0, 3)][2] = P(1, 0); dk[T(0, 3, 1, 2)][0] = P(1, 0); dk[T(0, 3, 1, 2)][1] = P(-1, 0); dk[T(0, 3, 1, 2)][2] = P(0, 1); dk[T(0, 3, 2, 1)][0] = P(1, 0); dk[T(0, 3, 2, 1)][1] = P(0, 1); dk[T(0, 3, 2, 1)][2] = P(-1, 0); dk[T(1, 3, 0, 2)][0] = P(-1, 0); dk[T(1, 3, 0, 2)][1] = P(1, 0); dk[T(1, 3, 0, 2)][2] = P(0, 1); dk[T(1, 3, 2, 0)][0] = P(0, 1); dk[T(1, 3, 2, 0)][1] = P(1, 0); dk[T(1, 3, 2, 0)][2] = P(-1, 0); dk[T(2, 3, 0, 1)][0] = P(-1, 0); dk[T(2, 3, 0, 1)][1] = P(0, 1); dk[T(2, 3, 0, 1)][2] = P(1, 0); dk[T(2, 3, 1, 0)][0] = P(0, 1); dk[T(2, 3, 1, 0)][1] = P(-1, 0); dk[T(2, 3, 1, 0)][2] = P(1, 0); set<P> used; P cur(0, 0); used.insert(cur); T t(0, 1, 2, 3); for (auto c : s) { int a = c - 'a'; auto diff = dk[t][a]; cur.first += diff.first; cur.second += diff.second; t = nxt[t][a]; used.insert(cur); } print(used.size()); return 0; }