QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#779774#8791. Tasks and BugsyanchengzhiWA 0ms3552kbC++202.4kb2024-11-24 21:43:232024-11-24 21:43:24

Judging History

你现在查看的是最新测评结果

  • [2024-11-24 21:43:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-11-24 21:43:23]
  • 提交

answer

//#include <bits/stdc++.h>
//		
//using namespace std;
//using par = pair<int, int>;
//const int N = 1e5 + 3;
//int T;
//int n, num;
//		
//		
//void work(){
//	string s;
//	map <int,int> id,p;
//	map<int,vector<int>> adj;
//	int cnt = 0;
//	while(getline(cin, s)){
//		istringstream input_stream(s);
//		string ss;input_stream >> ss;
//		int fa = stoi(ss.substr(3,s.size() - 4));
//		while(input_stream >> ss){
//			int len = ss.back() == ',' ? ss.size() - 4 : ss.size() - 3;
//			int son = stoi(ss.substr(3,len));
//			if(!id.count(son)) {
//				id[son] = ++cnt;
//				p[cnt] = son;
//			}
//			adj[id[son]].push_back(fa);
//		}
//	}
//	for(int i = 1;i <= cnt;i++){
//		if(i != 1) cout << "\n";
//		cout << "CS-" << p[i] << ": ";
////		sort(adj[i].begin(),adj[i].end());
//		for(int j = 0;j < (int)adj[i].size();j++) {
//			if(j) cout << ", ";
//			cout << "CS-" << adj[i][j];
//		}
////		sort(v.begin(), v.end());
////		for(auto y : v)
////			out.push_back(y);
////		
////		if(!out.empty()){
////			cout << "CS-" << x << ": ";
////			int sz = out.size();
////			for(int i = 0; i < sz; ++i)
////				cout << "CS-" << out[i] << ","[i == sz-1] << " "[i == sz-1];
////		}
//	}
//}
//		
//		
//int main(){
//	freopen("test.txt", "r", stdin);
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	int T = 1;
//	while(T--){
//		work();
//	}	
//	return 0;
//}
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <string>
#include <utility>
using namespace std;
using par = pair<int, int>;
const int N = 1e5 + 3;
int T;
int n, num;


void work(){
	string s;
	map<int,vector<int>> adj;
	int cnt = 0;
	while(getline(cin, s)){
		istringstream input_stream(s);
		string s1; char c; int fa, son;
		input_stream >> c >> c >> c >> fa >> c;
		while(input_stream >> c >> c >> c >> son){
			adj[son].push_back(fa);
			input_stream >> c;
		}
	}
	int p = 0;
	for(auto &[x, v] : adj){
		cout << " "[p == 0] << "\n"[p++ == 0];
		vector<int> out;
		sort(v.begin(), v.end());
		for(auto y : v)
			out.push_back(y);
		
		if(!out.empty()){
			cout << "CS-" << x << ": ";
			int sz = out.size();
			for(int i = 0; i < sz; ++i)
				cout << "CS-" << out[i] << ","[i == sz-1] << " "[i == sz-1];
		}
	}
}


int main(){
	// freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	while(T--){
		work();
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

CS-20: CS-1
CS-100: CS-239
CS-300: CS-239, CS-11111

output:


result:

wrong answer 1st lines differ - expected: 'CS-1: CS-20', found: ''