답안 #990722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990722 2024-05-31T05:55:18 Z vjudge1 Dijamant (COI16_dijament) C++17
0 / 100
2 ms 604 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 10;
map<string, int> st;
map<int, string> inv;
set<string> Str;
vector<int> G[N];
bitset<N> Df[N];

int main()
{
  int n;
  cin >> n;
  int cur = 0;
  for(int i = 0; i < n; i ++)
    {
      string k;
      cin >> k;
      string temp; cin >> temp;

      bool ok = true;
      //cerr << k << endl;
      ok &= (Str.count(k) == 0);
      // cerr << "ok = " << ok << endl;
      while(true)
	{
	  cin >> temp;
	  if(temp == ";")
	    break;
	  if(st.count(temp) == 0)
	    ok = false;
	  G[cur].push_back(st[temp]);
	  Df[cur] |= Df[G[cur].back()];
	  Df[cur].set(G[cur].back(), 1);
	}
      
      if(ok)
	{
	  // cerr << Df[cur] << endl;
	  for(int i = 0; i < cur && ok; i++)
	    {
	      if(!Df[cur].test(i)) continue;
	      
	      for(int j = i + 1; j < cur && ok; j++)
		{
		  if(!Df[cur].test(j)) continue;
		  
		  if(Df[i].test(j) || Df[j].test(i))
		    continue;
		  
		  bitset<N> A = Df[i] & Df[j];
		  if(A.any())
		    ok = false;
		  
		}
	    }
	  if(ok)
	    {
	      Str.insert(k);
	      inv[cur] = k;
	      st[k] = cur++;
	      cout << "ok\n";
	    }
	  else
	    {
	      G[cur].clear();
	      Df[cur].reset();
	      cout << "greska\n";
	    }
	}
      else
	{
	  // cerr << Df[cur] << endl;
	  Df[cur].reset();
	  G[cur].clear();
	  cout << "greska\n";
	}
    }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 2 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 2 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 2 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -