Submission #105220


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 A - Celsius と Fahrenheit
User noriok
Language C++11 (GCC 4.8.1)
Score 0
Code Size 1174 Byte
Status
Exec Time 29 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, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt
Case Name Status Exec Time Memory
00_sample_01.txt 21 ms 804 KB
00_sample_02.txt 21 ms 808 KB
00_sample_03.txt 20 ms 796 KB
test_01.txt 21 ms 796 KB
test_02.txt 22 ms 804 KB
test_03.txt 20 ms 804 KB
test_04.txt 21 ms 844 KB
test_05.txt 20 ms 800 KB
test_06.txt 20 ms 800 KB
test_07.txt 20 ms 924 KB
test_08.txt 20 ms 796 KB
test_09.txt 21 ms 800 KB
test_10.txt 21 ms 808 KB
test_11.txt 21 ms 928 KB
test_12.txt 22 ms 924 KB
test_13.txt 21 ms 792 KB
test_14.txt 22 ms 924 KB
test_15.txt 29 ms 708 KB
test_16.txt 22 ms 804 KB
test_17.txt 21 ms 708 KB
test_18.txt 21 ms 800 KB
test_19.txt 22 ms 804 KB
test_20.txt 23 ms 808 KB