土下座しながら探索中

主に競技プログラミング

Codeforces : April Fools Day Contest 2013

初めてApril Fools Day Contestなるものに参加してみた
一応始まる前に去年の問題を見てみたらなんと問題の説明が一切ない
これは・・・ん?
サンプルから全てを理解しろということなのですね
事前に確認していたので本番で混乱することはなかった
結果は6問中A,B,Dの3問AC
AでこけまくってしまいCにあまり時間をかけれなかったのが残念
E、Fは完全にエスパーゲー臭しかしなかった
まぁ、unratedだし気楽に
こういうのもなかなか面白いものですねと思います

※以下の問題概要は自分なりの解釈です
A:
問題概要:
1以上40以下のint型の変数aが与えられる
第a代アメリカ合衆国大統領のファミリーネーム(?)を答えよ

解法:
wikipediaをみて頑張る
ミドルとかの扱いが分からなかったのでassertで間違ったインプットを特定して頑張った

コード:

#include<iostream>
using namespace std;


int main(){
  int a;
  cin >> a;
  
  if(a == 1)
    {
      //assert(false);
      cout << "Washington" << endl;
    }  
  else if(a == 2)
    {    
      //assert(false);
      cout << "Adams" << endl;
    }  
  else if(a == 3)
    {    
      //assert(false);
      cout << "Jefferson" << endl;
    } 
  else if(a == 4)
    {   
      //assert(false);
      cout << "Madison" << endl;
    }  
  else if(a == 5)
    {   
      //assert(false);
      cout << "Monroe" << endl;
    }  
  else if(a == 6)
    {   
      //assert(false);
      cout << "Adams" << endl;
    }
  else if(a == 7)
    { 
      //assert(false);
      cout << "Jackson" << endl;
    }
  else if(a == 8)
    {    
      //assert(false);
      cout << "Van Buren" << endl;
    }
  else if(a == 9)
    {  
      //assert(false);
      cout << "Harrison" << endl;
    }  
  else if(a == 10)
    {
      //assert(false);
      cout << "Tyler" << endl;
    } 
  else if(a == 11)
    {   /
      //assert(false);
      cout << "Polk" << endl;
    }
  else if(a == 12)
    {   
      cout << "Taylor" << endl;
    }
  else if(a == 13)
    {
      cout << "Fillmore" << endl;
    }  
  else if(a == 14)
    {   
      cout << "Pierce" << endl;
    }  
  else if(a == 15)
    {   
      cout << "Buchanan" << endl;
    }  
  else if(a == 16)
    {   
      cout << "Lincoln" << endl;
    }
  else if(a == 17)
    {   
      cout << "Johnson" << endl;
    }  
  else if(a == 18)
    {   
      //assert(false);
      // cout << "Simpson Grant" << endl;
      cout << "Grant" << endl;
    }  
  else if(a == 19)
    {   
      //assert(false);
      cout << "Hayes" << endl;
      // cout << "Birchard Hayes" << endl;
    }  
  else if(a == 20)
    {   //assert(false);
      // cout << "Abram Garfield" << endl;
      cout << "Garfield" << endl;
    }  
  else if(a == 21)
    {   
      //assert(false);
      // cout << "Alan Arthur" << endl;
      cout << "Arthur" << endl;
    }
  else if(a == 22)
    {   
      cout << "Cleveland" << endl;
    }  
  else if(a == 23)
    {
      cout << "Harrison" << endl;
    }  
  else if(a == 24)
    {   
      cout << "Cleveland" << endl;
    }  
  else if(a == 25)
    {
      cout << "McKinley" << endl;
    }
  else if(a == 26)
    {   
      cout << "Roosevelt" << endl;
    }  
  else if(a == 27)
    {   //assert(false);
      // cout << "Howard Taft" << endl;
      cout << "Taft" << endl;
    }  
  else if(a == 28)
    {   
      cout << "Wilson" << endl;
    }  
  else if(a == 29)
    {   
      cout << "Harding" << endl;//ok - input 8 
    }
  else if(a == 30)
    {   //assert(false);
      // cout << "Calvin Coolidge" << endl;
      cout << "Coolidge" << endl;
    }
  else if(a == 31)
    {   
      //cout << "Clark Hoover" << endl;
      cout << "Hoover" << endl;
    }
  else if(a == 32)
    {   
      //cout << "Delano Roosevelt" << endl;
      cout << "Roosevelt" << endl;
    }
  else if(a == 33)
    {
      //assert(false);    
      //cout << "S. Truman" << endl;
      cout << "Truman" << endl;
    }
  else if(a == 34)
    {
      //assert(false);    
      //cout << "David Eisenhower" << endl;
      cout << "Eisenhower" << endl;
    }  
  else if(a == 35)
    {//assert(false);    
      //    cout << "Fitzgerald Kennedy" << endl;
      cout << "Kennedy" << endl;
    }
  else if(a == 36)
    {
      //assert(false);    
      //cout << "Baines Johnson" << endl;
      cout << "Johnson" << endl;
    }
  else if(a == 37)
    {   
      //assert(false);    
      cout << "Nixon" << endl;
      // cout << "Milhouse Nixon" << endl;
    }  
  else if(a == 38)
    {    
      //cout << "Earl Ford" << endl;
      cout << "Ford" << endl;
    }  
  else if(a == 39)
    {
      //cout << "Earl Carter" << endl;
      cout << "Carter" << endl;
    }
  else if(a == 40)
    {   
      //cout << "Wilson Reagan" << endl;
      cout << "Reagan" << endl;
    }


  return 0;
}

B:
問題概要:
QRコードを読み込んだ先には1と0からなるtextがあるので
そのtextのa1行a2列目の値をリターンせよ

解法:
textとってきて指定されたところをリターンする
QRコードをパソコン読み取るフリーソフト(Linux版)がみつからなかったので携帯でよみこんでURLを確認した
そこで確認したURLをブラウザのURLのとこに直接打ち込んでtextをとってきた
QRコード読めないと詰む

コード;

#include<iostream>

using namespace std;

string uho[] = {
"111111101010101111100101001111111",
"100000100000000001010110001000001",
"101110100110110000011010001011101",
"101110101011001001111101001011101",
"101110101100011000111100101011101",
"100000101010101011010000101000001",
"111111101010101010101010101111111",
"000000001111101111100111100000000",
"100010111100100001011110111111001",
"110111001111111100100001000101100",
"011100111010000101000111010001010",
"011110000110001111110101100000011",
"111111111111111000111001001011000",
"111000010111010011010011010100100",
"101010100010110010110101010000010",
"101100000101010001111101000000000",
"000010100011001101000111101011010",
"101001001111101111000101010001110",
"101101111111000100100001110001000",
"000010011000100110000011010000010",
"001101101001101110010010011011000",
"011101011010001000111101010100110",
"111010100110011101001101000001110",
"110001010010101111000101111111000",
"001000111011100001010110111110000",
"000000001110010110100010100010110",
"111111101000101111000110101011010",
"100000100111010101111100100011011",
"101110101001010000101000111111000",
"101110100011010010010111111011010",
"101110100100011011110110101110000",
"100000100110011001111100111100000",
"111111101101000101001101110010001"
};

int main()
{
  int a,b;
  cin >> a >> b;
  cout << uho[a][b] << endl;
  return 0;
}

C:
残りの15分で読解できず
D:
問題概要:
擬似コードらしき画像が張り付けてあるのでそれを解読して実際のコードに書き直し結果を出力せよ

解法:

string M = input
int    N = input
M = tolower(M)
char   c = 'a'+N
for i 0..M.size()-1
  if M[i] < c
    M[i] = toupper(M[i])
  else
    M[i] = tolower(M[i])
print M

こんな感じだと思う

コード:

#include<iostream>
#include<cctype>
#include<algorithm>
using namespace std;

int main()
{

  string s;
  int a;
  cin >> s >> a;
  transform(s.begin(),s.end(),s.begin(),::tolower);
  char c = (char)('a'+a);
  for(int i=0;i<s.size();i++)
    {
      if(s[i] < c)
	s[i] = toupper(s[i]);
      else
	s[i] = tolower(s[i]);
    }
  cout << s << endl;
  return 0;
}

E:
意味不明
F:
もはやエスパーゲー