Submission #743501

#TimeUsernameProblemLanguageResultExecution timeMemory
743501drkarlicio2107Dijamant (COI16_dijament)C++14
100 / 100
410 ms3812 KiB
#include <bits/stdc++.h>
using namespace std;
map <string, int> m;
int ind=1;
vector <string> ev;
const int OFF=1010;
bitset <OFF> l [1010];
bitset <OFF> pom;
int ko [1010][1010];
vector < int > pom2;
int main(){
	int n; cin >> n;
	for (int i=0; i<n+1; i++){
		string s;
		getline (cin, s);
		ev.clear ();
		if (i==0) continue;
		string tre="";
		for (int j=0; j<s.size(); j++){
			if (s [j]==' '){
				if (tre!=":" && tre!=";") ev.push_back (tre);
				tre="";
			}
			else tre+=s [j];
		}
		if (m [ev [0]]){
			cout << "greska\n";
			continue;
		}
		int g=0; pom2.clear ();
		for (int j=1; j<ev.size(); j++){
			if (m [ev [j]]==0){
				for (int k=0; k<n+1; k++) l [ind][k]=0;
				cout << "greska\n"; g=1;
				break;
			}
			pom2.push_back (m [ev [j]]);
			l [ind]=(l [ind] | l [m [ev [j]]]);
			l [ind][m [ev [j]]]=1;
		}
		if (g) continue;
		for (int j=0; j<n+1; j++) pom [j]=0;
		int br=0;
		sort (pom2.begin(), pom2.end()); reverse (pom2.begin(), pom2.end());
		if (pom2.size()>0) pom=l [pom2 [0]];
		for (int j=1; j<pom2.size(); j++){
			int x=pom2 [j];
			if (pom [x]==1) continue;
			//cout << l [x] << '\n';
			if ((pom & l [x])!=0) br=1;
			pom = (pom | l [x]);
		}
		if (br){
			cout << "greska\n";
			for (int j=0; j<n+1; j++) l [ind][j]=0;
			continue;
		}
		cout << "ok\n";
		m [ev [0]]=ind; ind++;
		//cout << ind << " " << l [ind] << endl;
	}
}

Compilation message (stderr)

dijament.cpp: In function 'int main()':
dijament.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for (int j=0; j<s.size(); j++){
      |                 ~^~~~~~~~~
dijament.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for (int j=1; j<ev.size(); j++){
      |                 ~^~~~~~~~~~
dijament.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int j=1; j<pom2.size(); j++){
      |                 ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...