Submission #990764

# Submission time Handle Problem Language Result Execution time Memory
990764 2024-05-31T07:59:26 Z vjudge1 Dijamant (COI16_dijament) C++17
13 / 100
269 ms 23128 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
int const N=1005;
int const mod=1e9+7;

map<string,bool> vis;
map<string,int> idx;
int cnt=1;
set<int> parent[N];
int main(){
	int n;
	cin>>n;
	string s;
	getline(cin,s);
	for(int i=0;i<n;i++){
		getline(cin,s);
		// cout<<s<<endl;
		vector<string> v;
		string t="";
		for(int i=0;i<s.length();i++){
			if(s[i]==' '){
				v.push_back(t);
				t="";
			}
			else
				t+=s[i];
		}
		v.push_back(t);
		if(vis[v[0]]){
			cout<<"greska"<<endl;
			continue;
		}
		bool b=1;
		for(int i=2;i<(v.size())-1;i++)
			if(vis[v[i]]==0)
				b=0;
		if(b==0){
			cout<<"greska"<<endl;
			continue;
		}
		//check diamond
		vector<int> pars;
		for(int i=2;i<(v.size())-1;i++)
			pars.push_back(idx[v[i]]);
		sort(pars.begin(), pars.end());
		reverse(pars.begin(), pars.end());
		// cout<<endl;
		b=1;
		set<int> p;
		for(auto id:pars){
			if(p.find(id)!=p.end())
				continue;
			for(auto x:parent[id]){
				if(p.find(x)!=p.end()){
					b=0;
					break;
				}
				p.insert(x);
			}
			if(b==0)
				break;
		}
		if(b==0){
			cout<<"greska"<<endl;
			continue;
		}
		for(auto i:pars)
			p.insert(i);
		for(auto i:p)
			cout<<i<<' ';
		cout<<endl;
		cout<<"ok"<<endl;
		vis[v[0]]=1;
		idx[v[0]]=cnt;
		parent[cnt]=p;
		cnt++;
	}
	return 0;
}

Compilation message

dijament.cpp: In function 'int main()':
dijament.cpp:22:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int i=0;i<s.length();i++){
      |               ~^~~~~~~~~~~
dijament.cpp:36:16: 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]
   36 |   for(int i=2;i<(v.size())-1;i++)
      |               ~^~~~~~~~~~~~~
dijament.cpp:45:16: 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]
   45 |   for(int i=2;i<(v.size())-1;i++)
      |               ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 3 ms 604 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 3 ms 604 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 269 ms 23128 KB Output isn't correct
2 Halted 0 ms 0 KB -