Submission #990704

# Submission time Handle Problem Language Result Execution time Memory
990704 2024-05-31T04:51:00 Z vjudge1 Dijamant (COI16_dijament) C++17
0 / 100
72 ms 348 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 1e3+5;
map<string, int> st;
vector<int> G[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;
      ok &= (st.count(k) == 0);
      
      while(true)
	{
	  cin >> temp;
	  if(temp == ";")
	    break;
	  if(st.count(temp) == 0)
	    ok = false;
	  else
	    G[cur].push_back(st[temp]);
	}
      
      if(ok)
	{
	  int cnt[cur] = {0};
	  for(int l : G[cur])
	    for(int j : G[l])
	      cnt[j]++;

	  for(int j = 0; j < cur; j++)
	    if(cnt[j] > 1)
	      ok = false;

	  if(ok)
	    cout << "ok\n";
	  else
	    cout << "greska\n";
	}
      else
	cout << "greska\n";
    }
  return 0;
}

Compilation message

dijament.cpp: In function 'int main()':
dijament.cpp:39:13: warning: array subscript j is outside array bounds of 'int [(<anonymous> + 1)]' [-Warray-bounds]
   39 |        cnt[j]++;
      |        ~~~~~^
dijament.cpp:36:8: note: while referencing 'cnt.337'
   36 |    int cnt[cur] = {0};
      |        ^~~
dijament.cpp:39:13: warning: array subscript j is outside array bounds of 'int [(<anonymous> + 1)]' [-Warray-bounds]
   39 |        cnt[j]++;
      |        ~~~~~^
dijament.cpp:36:8: note: while referencing 'cnt.337'
   36 |    int cnt[cur] = {0};
      |        ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -