Submission #743501

# Submission time Handle Problem Language Result Execution time Memory
743501 2023-05-17T12:45:22 Z drkarlicio2107 Dijamant (COI16_dijament) C++14
100 / 100
410 ms 3812 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4 ms 212 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4 ms 212 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 349 ms 572 KB Output is correct
2 Correct 410 ms 548 KB Output is correct
3 Correct 133 ms 400 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 13 ms 468 KB Output is correct
7 Correct 22 ms 592 KB Output is correct
8 Correct 41 ms 816 KB Output is correct
9 Correct 42 ms 724 KB Output is correct
10 Correct 12 ms 544 KB Output is correct
11 Correct 13 ms 596 KB Output is correct
12 Correct 321 ms 3812 KB Output is correct