Submission #105131


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 g_max = 0;

void calc_1(const string& s, int n, const string& start, Map& m, map<string, int>& memo) {
    if (memo[s] > n) return;
    memo[s] = n;
    
    if (g_max < n) {
        g_start = start;
        g_goal = s;
        g_max = n;
    }

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

void calc(Map& m) {
    map<string, int> memo;
    for (Map::iterator p = m.begin(); p != m.end(); ++p) {
        calc_1(p->first, 0, p->first, m, memo);
    }

    printf("1%s=%d%s\n", g_start.c_str(), g_max, 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 1175 Byte
Status
Exec Time 569 ms
Memory 16932 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
./Main.cpp:49: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 23 ms 808 KB
00_sample_02.txt 22 ms 680 KB
00_sample_03.txt 20 ms 804 KB
chokudai_solo_01.txt 20 ms 804 KB
chokudai_solo_02.txt 285 ms 16664 KB
chokudai_solo_03.txt 282 ms 16680 KB
chokudai_vs_cucumber_01.txt 569 ms 16800 KB
chokudai_vs_cucumber_02.txt 295 ms 16932 KB
chokudai_vs_cucumber_03.txt 289 ms 16732 KB
chokudai_vs_cucumber_04.txt 307 ms 16808 KB
chokudai_vs_cucumber_05.txt 301 ms 16804 KB
chokudai_vs_kensho_01.txt 22 ms 740 KB
chokudai_vs_kensho_02.txt 22 ms 736 KB
chokudai_vs_kensho_03.txt 21 ms 932 KB
chokudai_vs_kensho_04.txt 22 ms 808 KB
chokudai_vs_kensho_05.txt 297 ms 16808 KB
chokudai_vs_kensho_06.txt 349 ms 16756 KB
chokudai_vs_kensho_07.txt 379 ms 16792 KB
chokudai_vs_kensho_08.txt 294 ms 16804 KB
chokudai_vs_kensho_09.txt 278 ms 16680 KB
chokudai_vs_laycurse_01.txt 22 ms 804 KB
chokudai_vs_laycurse_02.txt 21 ms 808 KB
chokudai_vs_laycurse_03.txt 21 ms 804 KB
chokudai_vs_sanagipp_01.txt 20 ms 804 KB
chokudai_vs_sanagipp_02.txt 21 ms 804 KB
chokudai_vs_sanagipp_03.txt 22 ms 936 KB
chokudai_vs_sanagipp_04.txt 22 ms 808 KB
chokudai_vs_takahashikun_01.txt 21 ms 736 KB
chokudai_vs_takahashikun_02.txt 23 ms 772 KB
chokudai_vs_takahashikun_03.txt 22 ms 740 KB
chokudai_vs_takahashikun_04.txt 21 ms 756 KB
chokudai_vs_uwitenpen_01.txt 22 ms 808 KB
chokudai_vs_uwitenpen_02.txt 21 ms 800 KB
chokudai_vs_uwitenpen_03.txt 24 ms 804 KB