結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  mumin | 
| 提出日時 | 2020-11-20 21:46:00 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,430 bytes | 
| コンパイル時間 | 1,909 ms | 
| コンパイル使用メモリ | 175,984 KB | 
| 実行使用メモリ | 13,056 KB | 
| 最終ジャッジ日時 | 2024-07-23 12:50:34 | 
| 合計ジャッジ時間 | 2,905 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 | 
| other | AC * 4 WA * 10 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:34:13: warning: 'id' may be used uninitialized [-Wmaybe-uninitialized]
   34 |             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){
                x--;
            }
            if(id == 1){
                x--, y++;
                e[0] = node[2];
                e[1] = node[0];
                e[2] = node[1];
            }
            if(id == 2){
                x++;
                e[0] = node[1];
                e[1] = node[2];
                e[2] = node[0];
            }
        }
        else{
            k = 0;
            if(id == 0){
                y++;
            }
            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;
}
            
            
            
        