Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
6 HKer_YM 测试题目 C++ No Test Data 410 MS 9840 KB 1109 2020-08-27 04:30:18

Tests(6/100):


#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 300000 + 5; class Solution { public: map<int, string> mp; vector<string> ans; string str, tmp; int len; void dfs(int now) { if(now == len) { ans.push_back(tmp); return ; } for(auto i : mp[str[now] - '0']) { tmp += i; dfs(now + 1); tmp.pop_back(); } } vector<string> letterCombinations(string digits) { mp[2] = "abc"; mp[3] = "def"; mp[4] = "ghi"; mp[5] = "jkl"; mp[6] = "mno"; mp[7] = "pqrs"; mp[8] = "tuv"; mp[9] = "wxyz"; str = digits; len = str.length(); tmp = ""; if(len == 0) return ans; dfs(0); return ans; } }; int main(){ ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); string s; cin >> s; Solution tmp; vector<string> ans = tmp.letterCombinations(s); for(auto i : ans) { cout << i << endl; } return 0; }


Judgement Protocol: