Code Submission Evaluation System Login

HIIT Open 2018

Start:2018-05-26 11:00:00
End:2018-05-26 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2018 - Results
History
2018-05-26 14:42:58
2018-05-26 14:31:19
Task:Coins
Sender:DualCore
Submission time:2018-05-26 14:42:58
Language:C++
Status:READY
Result:WRONG ANSWER

Test results

testverdicttime (s)
#1WRONG ANSWER0.66 / 1.00details
#2TIME LIMIT EXCEEDED-- / 1.00details
#3TIME LIMIT EXCEEDED-- / 1.00details
#4ACCEPTED0.39 / 1.00details
#5WRONG ANSWER0.52 / 1.00details

Code

#include <iostream>
#include <string>
#include <vector>
#include <set>

int main()
{
  std::string first_line;
  int n;
  std::getline(std::cin, first_line);
  n = std::stoi(first_line);
  std::set<int> left, right;
  int previous = 0;
  for (int i = 0; i < n; ++i)
    {
      std::string line;
      std::getline(std::cin, line);
      std::size_t pos;
      int c = std::stoi(line, &pos);
      int s = std::stoi(line.substr(pos, line.length() - pos));

      (s == 1) ? left.insert(c) : right.insert(c);

      if (s == previous)
	{
	  s == 1 ? std::cout << ">\n" : std::cout << "<\n";
	  continue;
	}

      bool left_are_greater = true;
      bool right_are_greater = true;

      if (left.size() == 0)
	{
	  std::cout << "<\n";
	  previous = 2;
	  continue;
	}
      if (right.size() == 0)
	{
	  std::cout << ">\n";
	  previous = 1;
	  continue;
	}
      
      if (left.size() == right.size())
	{
	  for (auto leftit = left.rbegin(), rightit = right.rbegin(); leftit != left.rend(); ++leftit, ++rightit)
	    {
	      if (*leftit > *rightit)
		right_are_greater = false;
	      else
		left_are_greater = false;
	      if (!(left_are_greater || right_are_greater))
		break;
	    }
	  if (left_are_greater)
	    {
	      previous = 1;
	      std::cout << ">\n";
	    }
	  else if (right_are_greater)
	    {
	      previous = 2;
	      std::cout << "<\n";
	    }
	  else
	    {
	      previous = 0;
	      std::cout << "?\n";
	    }
	}
      else if (left.size() > right.size())
	{
	  for (auto leftit = left.rbegin(), rightit = right.rbegin(); rightit != right.rend(); ++leftit, ++rightit)
	    {
	      if (*leftit > *rightit)
		right_are_greater = false;
	      else
		left_are_greater = false;
	      if (!(left_are_greater || right_are_greater))
		break;
	    }
	  if (right_are_greater)
	    {
	      previous = 0;
	      std::cout << "?\n";
	    }
	  else
	    {
	      previous = 1;
	      std::cout << ">\n";
	    }
	}
      else
	{
	  for (auto leftit = left.rbegin(), rightit = right.rbegin(); leftit != left.rend(); ++leftit, ++rightit)
	    {
	      if (*leftit > *rightit)
		right_are_greater = false;
	      else
		left_are_greater = false;
	      if (!(left_are_greater || right_are_greater))
		break;
	    }
	  if (left_are_greater)
	    {
	      previous = 0;
	      std::cout << "?\n";
	    }
	  else
	    {
	      previous = 2;
	      std::cout << "<\n";
	    }
	}
      
    }

}

Test details

Test 1

Verdict: WRONG ANSWER

input
200000
175878 1
146174 1
4939 2
181388 1
27963 2
28393 1
101955 2
129380 1
53446 1
56883 2
41641 2
52574 1
185690 2
17672 2
187 2
29223 1
116434 2
81263 2
153912 2
...
view   save

correct output
>
>
>
>
>
>
>
>
>
>
>
>
?
?
?
?
?
?
?
?
...
view   save

user output
>
>
>
>
>
>
>
>
>
>
>
>
>
?
<
?
<
<
<
<
...
view   save

Test 2

Verdict: TIME LIMIT EXCEEDED

input
200000
1 2
2 1
3 2
4 1
5 2
6 1
7 2
8 1
9 2
10 1
11 2
12 1
13 2
14 1
15 2
16 1
17 2
18 1
19 2
...
view   save

correct output
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
...
view   save

user output
(no output)
view   save

Test 3

Verdict: TIME LIMIT EXCEEDED

input
200000
1 1
2 1
3 1
4 1
5 1
6 2
7 2
8 2
9 2
10 2
11 1
12 1
13 1
14 1
15 1
16 2
17 2
18 2
19 2
...
view   save

correct output
>
>
>
>
>
?
?
?
?
<
?
?
?
?
>
?
?
?
?
<
...
view   save

user output
(no output)
view   save

Test 4

Verdict: ACCEPTED

input
200000
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
...
view   save

correct output
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
...
view   save

user output
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
...
view   save

Test 5

Verdict: WRONG ANSWER

input
200000
188909 2
58944 1
26824 1
143263 2
108129 2
170746 1
129857 2
151652 1
92616 1
5122 1
85017 2
133713 2
130510 1
23167 2
55879 2
81852 1
117028 1
185678 1
5335 2
...
view   save

correct output
<
<
?
<
<
<
<
?
?
?
?
?
?
?
?
?
?
?
?
?
...
view   save

user output
<
<
?
<
<
<
<
?
>
>
>
?
>
?
<
?
>
>
>
?
...
view   save