Submission #18333


Source Code Expand

Copy
/*
  B.cpp
 */

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef int int_type;

// -- utility --
// C-style loop
#define FOR(x, a, b) for(int_type x = static_cast<int_type>(a); x < static_cast<int_type>(b); ++x)
#define FORN(x, n) FOR(x, 0, n)
// Ruby-style loop
#define TIMES(x, n) FOR(x, 0, n)
#define STEP(x, a, b, s) for(int_type x = static_cast<int_type>(a); s > 0 ? x <= static_cast<int_type>(b) : x >= static_cast<int_type>(b); x += static_cast<int_type>(s) )
#define UPTO(x, a, b) for(int_type x = static_cast<int_type>(a); x <= static_cast<int_type>(b); ++x)
#define DOWNTO(x, a, b) for(int_type x = static_cast<int_type>(a); x >= static_cast<int_type>(b); --x)
#define EACH(c, i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(cont, it, cond, ret) \
  bool ret = true; EACH(cont, it) { if(!(cond)) {ret=false;break;} }
#define ANY(cont, it, cond, ret) \
  bool ret = false; EACH(cont, it) { if(cond) {ret=true;break;} }


// debug
#define DUMP(x) std::cout << #x << " = " << to_s(x) << std::endl;

using namespace std;

template<typename T> string to_s(const T& v);
template<> string to_s(const string& v);
template<> string to_s(const bool& v);
template<typename T> string to_s(const vector<T>& v);
template<typename T> string to_s(const list<T>& v);
template<typename T> string to_s(const set<T>& v);
template<typename F, typename S> string to_s(const pair<F,S>& v);
template<typename K, typename V> string to_s(const map<K,V>& v);


int main(int argc, char *argv[])
{

  int n;
  cin >> n;
  
  map<string, string> dict;
  TIMES(k, n) {
    string s;
    cin >> s;

    string r = s;
    reverse(r.begin(), r.end());

    dict[r] = s;
  }

  EACH(dict, it) {
    cout << it->second << endl;
  }
  
  return 0;
}


template<typename T> string to_s(const T& v) { ostringstream oss; oss << v; return oss.str(); }
template<> string to_s(const string& v) { ostringstream oss; oss << '"' << v << '"'; return oss.str(); }
template<> string to_s(const bool& v) { ostringstream oss; oss << ( v ? "true" : "false") ; return oss.str(); } 
template<typename T> string to_s(const vector<T>& v) { ostringstream oss; oss << "["; EACH(v,i) oss << to_s(*i) << ","; oss << "]"; return oss.str(); }
template<typename T> string to_s(const list<T>& v) { ostringstream oss; oss << "("; EACH(v,i) oss << to_s(*i) << ","; oss << ")"; return oss.str(); }
template<typename T> string to_s(const set<T>& v) { ostringstream oss; oss << "{"; EACH(v,i) oss << to_s(*i) << ","; oss << "}"; return oss.str(); }
template<typename F, typename S> string to_s(const pair<F,S>& v) { ostringstream oss; oss << "<" << to_s(v.first) << " " << to_s(v.second) << ">"; return oss.str(); }
template<typename K, typename V> string to_s(const map<K,V>& v) { ostringstream oss; oss << "{"; EACH(v,i) oss << to_s(i->first) << " => " << to_s(i->second) << ","; oss << "}"; return oss.str(); }

Submission Info

Submission Time
Task B - さかさま辞書
User wataken44
Language C++ (GCC 4.4.7)
Score 100
Code Size 3301 Byte
Status AC
Exec Time 35 ms
Memory 824 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 28
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 01_rand_01.txt, 01_rand_02.txt, 01_rand_03.txt, 01_rand_04.txt, 01_rand_05.txt, 01_rand_06.txt, 01_rand_07.txt, 01_rand_08.txt, 01_rand_09.txt, 01_rand_10.txt, 02_long_01.txt, 02_long_02.txt, 02_long_03.txt, 03_short_01.txt, 03_short_02.txt, 03_short_03.txt, 04_max_01.txt, 04_max_02.txt, 04_max_03.txt, 04_max_04.txt, 04_max_05.txt, 05_samestring_01.txt, 05_samestring_02.txt, 05_samestring_03.txt, 05_samestring_04.txt, 05_samestring_05.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 23 ms 792 KB
00_sample_02.txt AC 22 ms 788 KB
01_rand_01.txt AC 35 ms 816 KB
01_rand_02.txt AC 23 ms 796 KB
01_rand_03.txt AC 23 ms 800 KB
01_rand_04.txt AC 23 ms 808 KB
01_rand_05.txt AC 23 ms 788 KB
01_rand_06.txt AC 24 ms 796 KB
01_rand_07.txt AC 23 ms 784 KB
01_rand_08.txt AC 22 ms 788 KB
01_rand_09.txt AC 22 ms 788 KB
01_rand_10.txt AC 27 ms 784 KB
02_long_01.txt AC 23 ms 784 KB
02_long_02.txt AC 23 ms 824 KB
02_long_03.txt AC 22 ms 784 KB
03_short_01.txt AC 23 ms 796 KB
03_short_02.txt AC 23 ms 784 KB
03_short_03.txt AC 23 ms 768 KB
04_max_01.txt AC 23 ms 768 KB
04_max_02.txt AC 24 ms 788 KB
04_max_03.txt AC 24 ms 784 KB
04_max_04.txt AC 23 ms 792 KB
04_max_05.txt AC 23 ms 808 KB
05_samestring_01.txt AC 25 ms 816 KB
05_samestring_02.txt AC 26 ms 788 KB
05_samestring_03.txt AC 23 ms 784 KB
05_samestring_04.txt AC 25 ms 788 KB
05_samestring_05.txt AC 25 ms 792 KB