Submission #123639

# Submission time Handle Problem Language Result Execution time Memory
123639 2019-07-01T21:27:32 Z sams Dijamant (COI16_dijament) C++14
100 / 100
1996 ms 8708 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e3+10;

int n, N;
int nd, mk[maxn][maxn];
map<string, int> conv;

int main()
{
	cin >> n;
	N = n;

	while(N--)
	{
		string c, pt;
		cin >> c >> pt;

		set<string> II;
		vector<int> g;

		while(true)
		{
			string ss;
			cin >> ss;

			if(ss == ";") break;

			II.insert(ss);
		}

		if(conv.find(c) != conv.end())
		{
			cout << "greska\n";
			
			continue;
		}
		
		int ok = 0;

		conv[c] = ++nd;

		for(auto ii: II)
		{
			if(conv.find(ii) == conv.end())
			{
				ok = 1;
				break;
			}

			g.push_back(conv[ii]);
		}

		if(ok)
		{
			conv.erase(c);
			nd--;
			cout << "greska\n";
			
			continue;
		}

		for(int i = 0 ; i < g.size() ; ++i)
		{
			for(int j = i+1 ; j < g.size() ; ++j)
			{
				int a = g[i], b = g[j];

				if(mk[a][b] == 1 || mk[b][a] == 1) continue;
				
				for(int k = 1 ; k < nd ; ++k)
				{
					if(mk[a][k] == 1 && mk[b][k] == 1)
					{
						ok = 1;
						break;
					}
				}
			}

			if(ok) break;
		}

		if(ok)
		{
			nd--;
			conv.erase(c);

			cout << "greska\n";
			
			continue;
		}

		for(int u: g)
		{
			mk[nd][u] = 1;

			for(int i = 1 ; i < nd ; ++i)
				if(mk[u][i]) mk[nd][i] = 1;
		}

		cout << "ok\n";

		/*for(int i = 1 ; i <= nd ;++i)
		{
			for(int j = 1 ; j <= nd ; ++j)
			{
				cout << mk[i][j] << " \n"[j == nd];
			}
		}*/
	}
}

Compilation message

dijament.cpp: In function 'int main()':
dijament.cpp:65:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0 ; i < g.size() ; ++i)
                   ~~^~~~~~~~~~
dijament.cpp:67:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = i+1 ; j < g.size() ; ++j)
                      ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 10 ms 760 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 10 ms 760 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 13 ms 376 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 692 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 3 ms 380 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1722 ms 7968 KB Output is correct
2 Correct 1996 ms 8708 KB Output is correct
3 Correct 485 ms 4600 KB Output is correct
4 Correct 7 ms 1016 KB Output is correct
5 Correct 10 ms 2040 KB Output is correct
6 Correct 22 ms 1576 KB Output is correct
7 Correct 43 ms 1656 KB Output is correct
8 Correct 82 ms 1788 KB Output is correct
9 Correct 85 ms 1656 KB Output is correct
10 Correct 20 ms 1272 KB Output is correct
11 Correct 19 ms 1272 KB Output is correct
12 Correct 1582 ms 7448 KB Output is correct