How does toph handle Go submissions?

A problem I tried to solve today was Games of Strings. A quite simple problem but when I tried to implement my solution with golang it failed. In fact it gave weird results for the same submission. Some gave WA while some gave TLE!
These are the sources in cpp and golang,

The cpp one:

code spoiler
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;

  auto strings = set<string>();
  for (int x = 0; x < n; x++) {
    string input;
    cin >> input;

  int k;
  cin >> k;

  auto it = strings.begin();
  for (int x = 0; x < k; x++) {
    cout << *it;
    if (it == strings.end())
  cout << '\n';

  return 0;

And the go code:

code spoiler
package main

import (

func main() {
	var n int
	fmt.Scanf("%d", &n)

	list := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &list[i])


	var k int
	fmt.Scanf("%d", &k)

	for idx := 0; idx < k; idx++ {
		if idx == len(list) {


The solutions are virtually the same and gives same result in my local environment. However toph seems to not like golang that much.

Hey @shantanu404, thank you for bringing this to my attention. I will look into it.

In the future, if you see any issue like this, can you please @-mention me? That way I will see your post immediately.

1 Like