結果
問題 | No.1292 パタパタ三角形 |
ユーザー | mumin |
提出日時 | 2020-11-20 21:52:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 60 ms / 2,000 ms |
コード長 | 1,622 bytes |
コンパイル時間 | 1,749 ms |
コンパイル使用メモリ | 176,496 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2024-07-23 12:54:46 |
合計ジャッジ時間 | 2,803 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:37:13: warning: 'id' may be used uninitialized [-Wmaybe-uninitialized] 37 | if(id == 2){ | ^~ main.cpp:21:13: note: 'id' was declared here 21 | int id; | ^~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int,int>; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; set<P> se; se.insert(P(0,0)); int x, y; x = y = 0; vector<char> node(3); node[0] = 'a', node[1] = 'b', node[2] = 'c'; int k = 0; rep(i,s.size()){ vector<char> e(3); int id; rep(j,3) if(s[i] == node[j]) id = j; if(k == 0){ k = 1; if(id == 0){ y--; e[0] = node[0]; e[1] = node[1]; e[2] = node[2]; } if(id == 1){ x--, y++; e[0] = node[2]; e[1] = node[0]; e[2] = node[1]; } if(id == 2){ y++; e[0] = node[1]; e[1] = node[2]; e[2] = node[0]; } } else{ k = 0; if(id == 0){ y++; e[0] = node[0]; e[1] = node[1]; e[2] = node[2]; } if(id == 1){ y--; e[0] = node[2]; e[1] = node[0]; e[2] = node[1]; } if(id == 2){ x++, y--; e[0] = node[1]; e[1] = node[2]; e[2] = node[0]; } } se.insert(P(x,y)); node = e; } cout << se.size() << endl; }