답안 #990723

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

using namespace std;

const int N = 1001;
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 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Incorrect 2 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Incorrect 2 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 320 ms 3088 KB Output isn't correct
2 Halted 0 ms 0 KB -