Submission #105206


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 1177 Byte
Status
Exec Time 26 ms
Memory 928 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 21 ms 792 KB
00_sample_02.txt 21 ms 788 KB
00_sample_03.txt 21 ms 792 KB
chokudai_solo_01.txt 21 ms 784 KB
chokudai_solo_02.txt 21 ms 796 KB
chokudai_solo_03.txt 20 ms 924 KB
chokudai_vs_cucumber_01.txt 21 ms 880 KB
chokudai_vs_cucumber_02.txt 21 ms 924 KB
chokudai_vs_cucumber_03.txt 22 ms 928 KB
chokudai_vs_cucumber_04.txt 22 ms 916 KB
chokudai_vs_cucumber_05.txt 22 ms 916 KB
chokudai_vs_kensho_01.txt 23 ms 836 KB
chokudai_vs_kensho_02.txt 22 ms 924 KB
chokudai_vs_kensho_03.txt 22 ms 920 KB
chokudai_vs_kensho_04.txt 22 ms 920 KB
chokudai_vs_kensho_05.txt 22 ms 924 KB
chokudai_vs_kensho_06.txt 22 ms 928 KB
chokudai_vs_kensho_07.txt 21 ms 928 KB
chokudai_vs_kensho_08.txt 22 ms 928 KB
chokudai_vs_kensho_09.txt 23 ms 812 KB
chokudai_vs_laycurse_01.txt 23 ms 808 KB
chokudai_vs_laycurse_02.txt 23 ms 924 KB
chokudai_vs_laycurse_03.txt 20 ms 840 KB
chokudai_vs_sanagipp_01.txt 20 ms 792 KB
chokudai_vs_sanagipp_02.txt 19 ms 924 KB
chokudai_vs_sanagipp_03.txt 19 ms 920 KB
chokudai_vs_sanagipp_04.txt 19 ms 924 KB
chokudai_vs_takahashikun_01.txt 21 ms 796 KB
chokudai_vs_takahashikun_02.txt 21 ms 924 KB
chokudai_vs_takahashikun_03.txt 26 ms 800 KB
chokudai_vs_takahashikun_04.txt 23 ms 812 KB
chokudai_vs_uwitenpen_01.txt 23 ms 920 KB
chokudai_vs_uwitenpen_02.txt 22 ms 928 KB
chokudai_vs_uwitenpen_03.txt 22 ms 920 KB