Submission #83493

# Submission time Handle Problem Language Result Execution time Memory
83493 2018-11-08T10:43:35 Z nikolapesic2802 Take-out (POI13_usu) C++14
0 / 100
540 ms 57952 KB
#include <bits/stdc++.h>

#define ll long long
#define pb push_back

using namespace std;

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	int n,k;
	scanf("%i %i",&n,&k);
	//printf("%i %i",n,k);
	char s[n];
	scanf("%s",s);
	//cout << s;
	int i=0,j=n-1;
	int c=1,b=k;
	set<int> index;
	while(i<=j)
	{
		c=1,b=k;
		index.clear();
		while(c>=0&&b>=0)
		{
			index.insert(i);
			if(s[i]=='c')
			c--;
			else
			b--;
			i++;
		}
		i--;
		if(s[i]=='c')
			c++;
			else
			b++;
		index.erase(i);
		i--;
		while(c>0||b>0)
		{
			index.insert(j);
			if(s[j]=='c')
			{
				c--;
				if(c<0)
				{
					assert(s[i]=='c');
					index.erase(i);
					i--;
					c++;
				}
			}
			else
			{
				b--;
				if(b<0)
				{
					assert(s[i]=='b');
					index.erase(i);
					i--;
					b++;
				}
			}
			j--;
		}
		i++;
		for(auto p:index)
		{
			printf("%i ",p+1);
		}
		printf("\n");
	}
    return 0;
}

Compilation message

usu.cpp: In function 'int main()':
usu.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
usu.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s);
  ~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 716 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 848 KB Output is correct
2 Runtime error 3 ms 848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1208 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 2696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 3228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 540 ms 57952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -