Problem:
B: たぬきつね
問題
謎の装置 $M$ があり,この装置に Tanuki と Fox を入れると, 装置から一匹の動物が出てくる（以下, Tanuki を $T$ ,Foxを $F$ とする）.
$M(x, y)$ は,装置 $M$ に $x, y$ の順で動物を入れて出てきた動物を表す.
色々試した結果,以下のことがわかった.
$M(T, T) = T$
$M(T, F) = F$
$M(F, T) = T$
$M(F, F) = T$
あなたは,一列に並んでいる動物たち $P_1, P_2, ... , P_N$ を以下のように装置に入れていった.
$M(....M(M(P_1,P_2), P_3)...., P_N)$
最後に出てくる動物を答えよ.
制約
$2 \leq N \leq 10^{5}$
$P_i$ は $T$ か $F$ の一文字
入力形式
入力は以下の形式で与えられる.
$N$
$P_1\ P_2\ ...\ P_N$
出力
最後に出てくる動物を表す文字 $T$ または $F$ を出力せよ.また,末尾に改行も出力せよ.
サンプル
サンプル入力 1
3
F T T
サンプル出力 1
T
サンプル入力 2
7
F T T F T T F
サンプル出力 2
F

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    string ans = "T";
    for(int i=0;i<n;i++){
        string p;
        cin >> p;
        if(ans=="T"){
            ans = p;
        }
        else{
            ans = "T";
        }
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3160
final_rank: 3

code_snippet: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

string f(string a, string b){
    if(a == "T" && b == "F")return "F";
    return "T";
}

signed main(void) {
    int n;
    cin >> n;
    string ans;
    cin >> ans;
    rep(i,n-1){
        string t;
        cin >> t;
        ans = f(ans, t);
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3160
final_rank: 7

code_snippet: #include <iostream>
#include <string>
#include <vector>
using namespace std;

bool calc(bool a, bool b) {
    if (a && !b) return false;
    else return true;
}

int main() {
    int N; cin >> N;
    vector<bool> a(N);
    for (int i = 0; i < N; ++i) {
        string s; cin >> s;
        if (s == "T") a[i] = true;
        else a[i] = false;
    }
    bool res = calc(a[0], a[1]);
    for (int i = 2; i < N; ++i) {
        res = calc(res, a[i]);
    }
    if (res) cout << "T" << endl;
    else cout << "F" << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3172
final_rank: 4

code_snippet: #include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

string func(string s, string t){
    if(s=="T" && t=="F") return "F";
    else return "T";
}

int main(){
    int n; cin>>n;
    vector<string> p(n);
    for(int i=0; i<n; i++) cin>>p[i];

    string ans=func(p[0], p[1]);
    for(int i=2; i<n; i++){
        ans=func(ans, p[i]);
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 8460
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int A[100001];
int main(){
	cin>>N;
	REP(i,N){
		string s;
		cin>>s;
		if(s[0]=='T'){
			A[i]=1;
		}else{
			A[i]=0;
		}
	}
	REP(i,N-1){
		if(A[i]==1&&A[i+1]==0){
			A[i+1]=0;
		}else{
			A[i+1]=1;
		}
	}
	if(A[N-1]==1){
		cout<<"T"<<endl;
	}else{
		cout<<"F"<<endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3520
final_rank: 5

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;

int main() {
    int n; cin >> n;
    string bef;
    rep(i, n) {
        string s; cin >> s;
        if (i) {
            if (bef == "T" && s == "F") {
                s = "F";
            } else {
                s = "T";
            }
        }
        bef = s;
    }
    cout << bef << endl;
    
}
accuracy: 1
time_ms: 10
memory_kb: 3140
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int n;
vec<string> v;

string f(string a, string b) {
  if (a == "T" and b == "F") {
    return "F";
  }
  return "T";
}

signed main() {
  cin >> n;
  v.resize(n);
  rep (i, n) {
    cin >> v[i];
  }

  string ans = f(v[0], v[1]);
  repp (i, 1, n-1) {
    ans = f(ans, v[i+1]);
  }

  cout << ans << endl;

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 8412
final_rank: 9

code_snippet: #include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd${0:#:TARGET}

string funami(string a, string b)
{
    if (a == "T" && b == "F") {
        return "F";
    } else {
        return "T";
    }
}

string mmnmm(int yui, string left)
{
    if (yui) {
        string right;
        cin >> right;
        return mmnmm(yui-1, funami(left, right));
    } else {
        return left;
    }
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    Int(n);
    string st; cin >> st;
    cout << mmnmm(n-1, st) << endl;

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 23468
final_rank: 6

code_snippet: #include <iostream>
#include <algorithm>

using namespace std;

int N;
string P;
string m1;

string f(string a, string b){
  if(a == "T" && b == "F"){
    return "F";
  }
  return "T";
}

int main(){
  cin >> N;
  cin >> m1;
  for(int i=0;i<N-1;i++){
    cin >> P;
    m1 = f(m1, P);
  }

  cout << m1 << endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3160
final_rank: 7

code_snippet: #define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	REP(i, n - 1) {
		string a;
		cin >> a;
		if (s == "T"&&a == "F") {
			s = "F";
		}
		else s = "T";
	}
	cout << s << endl;
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3140
final_rank: 1