提出 #105233


ソースコード 拡げる

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);
}

提出情報

提出日時
問題 C - 変わった単位
ユーザ noriok
言語 C++11 (GCC 4.8.1)
得点 0
コード長 1174 Byte
結果
実行時間 1026 ms
メモリ 374064 KB

コンパイルエラー

./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);
                                    ^

テストケース

セット名 得点 / 配点 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_01.txt 24 ms 796 KB
00_sample_02.txt 23 ms 796 KB
00_sample_03.txt 21 ms 920 KB
chokudai_solo_01.txt 20 ms 916 KB
chokudai_solo_02.txt 291 ms 20272 KB
chokudai_solo_03.txt 1026 ms 374064 KB
chokudai_vs_cucumber_01.txt 620 ms 22052 KB
chokudai_vs_cucumber_02.txt 319 ms 23848 KB
chokudai_vs_cucumber_03.txt 293 ms 23832 KB
chokudai_vs_cucumber_04.txt 303 ms 22060 KB
chokudai_vs_cucumber_05.txt 297 ms 20264 KB
chokudai_vs_kensho_01.txt 23 ms 808 KB
chokudai_vs_kensho_02.txt 22 ms 924 KB
chokudai_vs_kensho_03.txt 23 ms 900 KB
chokudai_vs_kensho_04.txt 21 ms 796 KB
chokudai_vs_kensho_05.txt 303 ms 22048 KB
chokudai_vs_kensho_06.txt 370 ms 31000 KB
chokudai_vs_kensho_07.txt 369 ms 23856 KB
chokudai_vs_kensho_08.txt 312 ms 22056 KB
chokudai_vs_kensho_09.txt 284 ms 22060 KB
chokudai_vs_laycurse_01.txt 22 ms 920 KB
chokudai_vs_laycurse_02.txt 25 ms 924 KB
chokudai_vs_laycurse_03.txt 23 ms 924 KB
chokudai_vs_sanagipp_01.txt 22 ms 920 KB
chokudai_vs_sanagipp_02.txt 24 ms 928 KB
chokudai_vs_sanagipp_03.txt 23 ms 796 KB
chokudai_vs_sanagipp_04.txt 21 ms 924 KB
chokudai_vs_takahashikun_01.txt 22 ms 808 KB
chokudai_vs_takahashikun_02.txt 22 ms 804 KB
chokudai_vs_takahashikun_03.txt 22 ms 808 KB
chokudai_vs_takahashikun_04.txt 21 ms 920 KB
chokudai_vs_uwitenpen_01.txt 23 ms 832 KB
chokudai_vs_uwitenpen_02.txt 28 ms 860 KB
chokudai_vs_uwitenpen_03.txt 26 ms 816 KB