Submission #104956


Source Code Expand

Copy
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
#define For(i,x) for (int i=0; i<(int)(x); i++)

typedef map<string, vector< pair<int, string> > > Map;

string g_start;
string g_goal;
int nmax = 0;

void calc_1(const string& s, int n, const string& start, Map& m) {
    if (nmax < n) {
        g_start = start;
        g_goal = s;
        nmax = n;
    }

    const vector< pair<int, string> >& v = m[s];
    For(i, v.size()) {
        calc_1(v[i].second, n * v[i].first, start, m);
    }
}

void calc(Map& m) {
    for (Map::iterator p = m.begin(); p != m.end(); ++p) {
        calc_1(p->first, 1, p->first, m);
    }

    printf("1%s=%d%s\n", g_start.c_str(), nmax, g_goal.c_str());
}

int main() {
    int n;
    scanf("%d", &n);

    Map m;
    For(i, n) {
        char s[100], t[100];
        int x;
        scanf("%s %d %s", s, &x, t);

        m[s].push_back(make_pair(x, t));
    }

    calc(m);
}

Submission Info

Submission Time
Task C - 変わった単位
User noriok
Language C++11 (GCC 4.8.1)
Score 0
Code Size 1018 Byte
Status
Exec Time 400 ms
Memory 16884 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:38:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
./Main.cpp:44:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s %d %s", s, &x, t);
                                    ^

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 100 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, chokudai_solo_01.txt, chokudai_solo_02.txt, chokudai_solo_03.txt, chokudai_vs_cucumber_01.txt, chokudai_vs_cucumber_02.txt, chokudai_vs_cucumber_03.txt, chokudai_vs_cucumber_04.txt, chokudai_vs_cucumber_05.txt, chokudai_vs_kensho_01.txt, chokudai_vs_kensho_02.txt, chokudai_vs_kensho_03.txt, chokudai_vs_kensho_04.txt, chokudai_vs_kensho_05.txt, chokudai_vs_kensho_06.txt, chokudai_vs_kensho_07.txt, chokudai_vs_kensho_08.txt, chokudai_vs_kensho_09.txt, chokudai_vs_laycurse_01.txt, chokudai_vs_laycurse_02.txt, chokudai_vs_laycurse_03.txt, chokudai_vs_sanagipp_01.txt, chokudai_vs_sanagipp_02.txt, chokudai_vs_sanagipp_03.txt, chokudai_vs_sanagipp_04.txt, chokudai_vs_takahashikun_01.txt, chokudai_vs_takahashikun_02.txt, chokudai_vs_takahashikun_03.txt, chokudai_vs_takahashikun_04.txt, chokudai_vs_uwitenpen_01.txt, chokudai_vs_uwitenpen_02.txt, chokudai_vs_uwitenpen_03.txt
Case Name Status Exec Time Memory
00_sample_01.txt 22 ms 928 KB
00_sample_02.txt 21 ms 800 KB
00_sample_03.txt 21 ms 800 KB
chokudai_solo_01.txt 22 ms 936 KB
chokudai_solo_02.txt 273 ms 16684 KB
chokudai_solo_03.txt 268 ms 16800 KB
chokudai_vs_cucumber_01.txt 400 ms 16792 KB
chokudai_vs_cucumber_02.txt 274 ms 16796 KB
chokudai_vs_cucumber_03.txt 286 ms 16800 KB
chokudai_vs_cucumber_04.txt 307 ms 16812 KB
chokudai_vs_cucumber_05.txt 306 ms 16808 KB
chokudai_vs_kensho_01.txt 20 ms 928 KB
chokudai_vs_kensho_02.txt 22 ms 804 KB
chokudai_vs_kensho_03.txt 21 ms 804 KB
chokudai_vs_kensho_04.txt 21 ms 804 KB
chokudai_vs_kensho_05.txt 289 ms 16884 KB
chokudai_vs_kensho_06.txt 300 ms 16796 KB
chokudai_vs_kensho_07.txt 307 ms 16760 KB
chokudai_vs_kensho_08.txt 290 ms 16808 KB
chokudai_vs_kensho_09.txt 301 ms 16800 KB
chokudai_vs_laycurse_01.txt 22 ms 744 KB
chokudai_vs_laycurse_02.txt 21 ms 932 KB
chokudai_vs_laycurse_03.txt 22 ms 800 KB
chokudai_vs_sanagipp_01.txt 22 ms 804 KB
chokudai_vs_sanagipp_02.txt 21 ms 804 KB
chokudai_vs_sanagipp_03.txt 21 ms 800 KB
chokudai_vs_sanagipp_04.txt 21 ms 808 KB
chokudai_vs_takahashikun_01.txt 21 ms 796 KB
chokudai_vs_takahashikun_02.txt 21 ms 924 KB
chokudai_vs_takahashikun_03.txt 21 ms 800 KB
chokudai_vs_takahashikun_04.txt 21 ms 804 KB
chokudai_vs_uwitenpen_01.txt 22 ms 800 KB
chokudai_vs_uwitenpen_02.txt 21 ms 800 KB
chokudai_vs_uwitenpen_03.txt 23 ms 804 KB