Submission #159683

# Submission time Handle Problem Language Result Execution time Memory
159683 2019-10-24T00:37:24 Z socho Zamjena (COCI18_zamjena) C++14
14 / 70
300 ms 65540 KB
#include "bits/stdc++.h"
using namespace std;

map<string, vector<string> > adj;
map<string, bool> vis;

bool isn(string s) {
	char x = s[0];
	if (x >= '0' && x <= '9') return true;
	return false;
}

int dfsw(string s, string last) {
	int count = isn(s);
	vis[s] = true;
	for (int i=0; i<adj[s].size(); i++) {
		string other = adj[s][i];
		if (other == last) continue;
		if (other == s) continue;
		count += dfsw(other, s);
	}
	return count;
}

int main() {
	
	int n;
	cin >> n;
	string a1[n], a2[n];
	for (int i=0; i<n; i++) cin >> a1[i];
	for (int i=0; i<n; i++) cin >> a2[i];
	
	for (int i=0; i<n; i++) {
		string a = a1[i], b = a2[i];
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	for (int i=0; i<n; i++) {
		string a = a1[i];
		if (!vis[a]) {
			int re = dfsw(a, "");
			// cout << a << ' ' << re << endl;
			if (re > 1) {
				cout << "NE" << endl;
				exit(0);
			}
		}
	}
	cout << "DA" << endl;
	exit(0);
   
}

Compilation message

zamjena.cpp: In function 'int dfsw(std::__cxx11::string, std::__cxx11::string)':
zamjena.cpp:16:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<adj[s].size(); i++) {
                ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 136 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 187 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 300 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -