結果

問題 No.331 CodeRunnerでやれ
ユーザー itezpaceitezpace
提出日時 2016-10-14 07:50:43
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,298 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 64,452 KB
実行使用メモリ 92,064 KB
平均クエリ数 9.29
最終ジャッジ日時 2023-09-24 00:37:04
合計ジャッジ時間 8,541 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
24,288 KB
testcase_01 AC 152 ms
24,048 KB
testcase_02 AC 173 ms
23,368 KB
testcase_03 AC 174 ms
23,656 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<pair<int,int>> v;
int calc(int x,int y){
  int ret=0;
  for(int i=0;i<v.size();++i){
    if(x==v[i].first && y==v[i].second){
      ret=1;
      break;
    }
  }
  return ret;
}
int main(){
  int x=0,y=0;
  v.push_back(make_pair(x,y));
  int f_i=0,f_w=0,mode=0,d=0,d_p=0;
  while(1){
    string s1,s2;getline(cin,s1);
    if(s1=="Merry Christmas!"){
      break;
    }
    if(s1=="20151224"){
      s2="F";
      cout<<s2<<endl;
      if(d==0) y-=1;
      if(d==1) x+=1;
      if(d==2) y+=1;
      if(d==3) x-=1;
      v.push_back(make_pair(x,y));
      continue;
    }
    int a=stoi(s1);
    if(f_i==0 && a!=0){
      s2="F";
      cout<<s2<<endl;
      if(d==0) y-=1;
      if(d==1) x+=1;
      if(d==2) y+=1;
      if(d==3) x-=1;
      v.push_back(make_pair(x,y));
      continue;
    } else if(f_i==0 && a==0){
      f_i=1;
    }
    if(calc(x,y)) mode=1;
    if(f_w==0 && a==0){
      if(mode==0){
        s2="R";
        if(d_p==0) d=1;
        if(d_p==1) d=2;
        if(d_p==2) d=3;
        if(d_p==3) d=0;
        d_p=d;
      } else {
        s2="L";
        if(d_p==0) d=3;
        if(d_p==1) d=0;
        if(d_p==2) d=1;
        if(d_p==3) d=2;
        d_p=d;
      }
      cout<<s2<<endl;
      f_w=1;
      continue;
    } else if(f_w==0 && a!=0){
      if(mode==0){
        s2="L";
        if(d_p==0) d=3;
        if(d_p==1) d=0;
        if(d_p==2) d=1;
        if(d_p==3) d=2;
        d_p=d;
      } else {
        s2="R";
        if(d_p==0) d=1;
        if(d_p==1) d=2;
        if(d_p==2) d=3;
        if(d_p==3) d=0;
        d_p=d;
      }
      cout<<s2<<endl;
      f_w=1;
      continue;
    } else if(f_w!=0 && a==0){
      if(mode==0){
        s2="R";
        if(d_p==0) d=1;
        if(d_p==1) d=2;
        if(d_p==2) d=3;
        if(d_p==3) d=0;
        d_p=d;
      } else {
        s2="L";
        if(d_p==0) d=3;
        if(d_p==1) d=0;
        if(d_p==2) d=1;
        if(d_p==3) d=2;
        d_p=d;
      }
      cout<<s2<<endl;
      continue;
    } else if(f_w!=0 && a!=0){
      s2="F";
      cout<<s2<<endl;
      if(d==0) y-=1;
      if(d==1) x+=1;
      if(d==2) y+=1;
      if(d==3) x-=1;
      v.push_back(make_pair(x,y));
      f_w=0;
      continue;
    }
  }
  return 0;
}
0