540 - Team Queue

All about problems in Volume 5. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 540- Team Queue, RTE

Post by uDebug » Tue Jan 21, 2014 2:28 pm

tiendaotd, shiam,

Thanks very much for the lovely test cases. They proved to be really helpful during testing / debugging.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

Noodlemon
New poster
Posts: 1
Joined: Wed Mar 26, 2014 3:14 pm

540 - Team Queue TLE

Post by Noodlemon » Wed Mar 26, 2014 3:19 pm

Hey all.
I've been getting the error TLE with this problem, and I know why I'm having it.

Code: Select all

import java.util.*;
import java.io.*;
class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;
	public InputReader(InputStream stream) {
		this.stream = stream;
	}
	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);

			} catch (IOException e) {

				throw new InputMismatchException();

			}

			if (numChars <= 0)

				return -1;

		}

		return buf[curChar++];

	}
	public int readInt() {
		int c = read();

		while (isSpaceChar(c))

			c = read();

		int sgn = 1;

		if (c == '-') {

			sgn = -1;

			c = read();
		}

		int res = 0;

		do {

			if (c < '0' || c > '9')

				throw new InputMismatchException();

			res *= 10;

			res += c - '0';

			c = read();

		} while (!isSpaceChar(c));

		return res * sgn;

	}


	public String readString() throws IOException {

		int c = read();

		while (isSpaceChar(c))

			c = read();

		StringBuilder res = new StringBuilder();

		do {

			res.appendCodePoint(c);

			c = read();

		} while (!isSpaceChar(c));

		return res.toString();

	}


	public boolean isSpaceChar(int c) {

		if (filter != null)

			return filter.isSpaceChar(c);

		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;

	}


	public String next() throws IOException {

		return readString();

	}


	public interface SpaceCharFilter {

		public boolean isSpaceChar(int ch);

	}

}


class OutputWriter {

	private final PrintWriter writer;


	public OutputWriter(OutputStream outputStream) {

		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));

	}


	public OutputWriter(Writer writer) {

		this.writer = new PrintWriter(writer);

	}


	public void print(Object...objects) {

		for (int i = 0; i < objects.length; i++) {

			if (i != 0)

				writer.print(' ');

			writer.print(objects[i]);

		}

	}


	public void printLine(Object...objects) {

		print(objects);

		writer.println();

	}


	public void close() {

		writer.close();

	}


	public void flush() {

		writer.flush();

	}


	}


class IOUtils {


	public static int[] readIntArray(InputReader in, int size) {

		int[] array = new int[size];

		for (int i = 0; i < size; i++)

			array[i] = in.readInt();

		return array;

	}


	}

class Main {

	void begin() throws IOException{
		InputReader in = new InputReader(System.in);
		OutputWriter out = new OutputWriter(System.out);
		int s = 0;
		int lol;
		int to = 0;
		boolean check = true;
		int scenarioNum = 1; String command = new String();
		LinkedList<Integer> queueList = new LinkedList<Integer>();
		while(true){
			int t = in.readInt();
			if(t == 0) break;
			int numTeams[] = new int[1000005];
			for(int i = 0; i < t; i++){
				int numElem = in.readInt();
				for(int j = 0; j < numElem; j++)
					numTeams[in.readInt()] = i;
			}
			out.printLine("Scenario #" + scenarioNum);
			do{
				command = in.readString();
				if(command.equals("ENQUEUE")){
					int enq = in.readInt();
					if(queueList.size() == 0){
						queueList.add(enq);
					}
					else{
						for(ListIterator<Integer> a = queueList.listIterator(); a.hasNext();){
							lol = a.next();
							if(numTeams[enq] == numTeams[lol]){
								check = false;
								s++;
							}
							if(check == true) s++;
						}
						to = s;
						queueList.add(to, enq);
					}
				}
				else if(command.equals("DEQUEUE")){
					out.printLine(queueList.removeFirst());
				}
				s = 0;
				to = 0;
				check = true;
			}while(!(command.equals("STOP")));
			out.printLine(); scenarioNum++;
		}
	}
	public static void main(String[] args) throws IOException {
	
		Main start = new Main();
		start.begin();
		
		
	}
}
It's the for loop for enqueue, right? Question is, how can I improve this? Should I stop using Java's built in linkedlist?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 540 - Team Queue TLE

Post by brianfry713 » Wed Mar 26, 2014 8:38 pm

Warning: A test case may contain up to 200000 (two hundred thousand) commands, so the implementation of the team queue should be efficient: both enqueing and dequeuing of an element should only take constant time.
http://acm.uva.es/board/viewtopic.php?t=10516
Check input and AC output for thousands of problems on uDebug!

lobato
New poster
Posts: 2
Joined: Fri Oct 17, 2014 12:42 am

Re: 540 - Team Queue

Post by lobato » Thu Oct 30, 2014 11:08 pm

I am getting Wrong Answer, although I checked all the text cases in the board and made a few more taste cases in UDebug, my program got all of them but I still have WA, does anybody have any test cases I could use or any tricky input.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <assert.h>
typedef struct persona {
	int data;
	int equipo;
} Persona;

typedef struct node {
	int data;
	struct node *next;
	struct node *previous;
} Node;

typedef struct queue {
	Node *head;
	Node *tail;

} Queue;

struct arreglo_nodos {
	Node *element;
};


void enqueue(Queue *q, int data) {
	Node *new = (Node*) malloc(sizeof(Node));
	new->data = data;

	if( q->head == NULL ) {
		q->tail = new;
		new->previous = NULL;
	}else {
		q->head->previous = new;
	}

	new->next = q->head;	
	q->head = new;
	new->previous = NULL;
}


void enqueue_team(Queue *q, Node *meter, int data ) {

	if( meter->previous == NULL ) {
		enqueue(q,data);
	}
	else {
		Node *new = (Node*)malloc(sizeof(Node));
		new->data = data;

		new->next = meter;
		meter->previous->next = new;
		new->previous = meter->previous;
		meter->previous = new;
		
	}
}


int dequeue( Queue *q ) {
	if( !is_empty(q) ) {
		int x = q->tail->data;
		if( q->head == q->tail ) {
			q->head = q->tail = NULL;
		} else {
			Node *temp = q->tail;
			q->tail = q->tail->previous;
			q->tail->next = NULL;
			free(temp);
		}
	return x;
	}
	else return -1;

}

Queue* new_queue() {
	Queue *q = (Queue*) malloc(sizeof(Queue));
	q->head = NULL;
	q->tail = NULL;
	return q;
}

int compare( const void *a, const void *b ) {
	Persona *uno = (Persona*) a;
	Persona *dos = (Persona*) b;

	return uno->data - dos->data;
}

int compare2( const void *a, const void *b ) {
	int *uno = (int*)a; 
	Persona *dos = (Persona*)b;
	return *uno - dos->data;
}

int is_empty(Queue *q){
	return q->head == NULL ? 1 : 0;
}

void empty(Queue *q){
	if(!is_empty(q)) {
		Node *current = q->head;
		Node *tmp;
		while(current != NULL ) {
			tmp = current->next;
			free(current);
			current = tmp;
		}

	}
}

int main(int argc, char *argv[]) {
	
	int teams, members, i,j,scenario = 1;

	while( scanf("%d", &teams) != EOF ) {
		if(!teams)  break;

		int **arr = (int**) malloc(sizeof(int*) * teams);
		int *indices = (int*) malloc(sizeof(int) * teams);
		int total = 0;

		for( i = 0 ; i < teams ; i++ ) {
			scanf("%d", &members);

			indices[i] = members;
			total += members;

			arr[i] = (int*) malloc(sizeof(int) * members);

			for( j = 0 ; j < members ; j++) {
				scanf("%d", &arr[i][j]);
			}
		}


		Persona *personas = (Persona*) malloc(sizeof(Persona) * total );
		int z = 0;
		for( i = 0 ; i < teams ; i++) {
			for( j = 0 ; j < indices[i] ; j++ ) {
				personas[z].data = arr[i][j];
				personas[z].equipo = i;
				z++;
			}
			free(arr[i]);
		}
		free(arr);
		free(indices);

		qsort(personas,total,sizeof(Persona), compare);


		char opcion[10];
		int elemento;

		Queue *fila = new_queue();

		struct arreglo_nodos colar[teams];

		for(i = 0 ; i < teams ; i++) {
			colar[i].element = NULL;
		}

		
		printf("Scenario #%i\n",scenario);	
		
		while( scanf("%s", opcion) ) {
			if(strcmp(opcion,"STOP") == 0) break;

			scanf("%d", &elemento);

			if( opcion[0] == 'E' ) {
				Persona *found = bsearch(&elemento, personas, total, sizeof(Persona), compare2);
				if( found != NULL ) {
					if( colar[found->equipo].element != NULL ) {
						enqueue_team(fila, colar[found->equipo].element, found->data );
						colar[found->equipo].element = (colar[found->equipo].element)->previous;
					}
					else {

						enqueue(fila,found->data);
						colar[found->equipo].element = fila->head;
					}
				}else{
					enqueue(fila,elemento);
				}
			}

			if( opcion[0] == 'D') {
				int n = dequeue(fila);
				if( n != -1 ) {
					printf("%i\n",n );

					Persona *found = bsearch(&n, personas, total, sizeof(Persona), compare2);
					if( (colar[found->equipo].element)->data == n ) {
						 colar[found->equipo].element = NULL;
					}
				}
			}
		}
		printf("\n");
		scenario++;
		free(personas);
		empty(fila);
		free(fila);
	}	


	return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 540 - Team Queue

Post by brianfry713 » Fri Oct 31, 2014 7:27 pm

Input:

Code: Select all

2
3 1 2 3
3 4 5 6
ENQUEUE 1
ENQUEUE 2
ENQUEUE 4
DEQUEUE
DEQUEUE
ENQUEUE 3
ENQUEUE 1
ENQUEUE 5
ENQUEUE 6
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 1
DEQUEUE
STOP
2
3 1 2 3
3 4 5 6
ENQUEUE 1
ENQUEUE 2
ENQUEUE 4
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 3
ENQUEUE 5
ENQUEUE 6
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 1
DEQUEUE
STOP
2
2 1 2
2 3 4
ENQUEUE 1
ENQUEUE 2
ENQUEUE 3
ENQUEUE 4
DEQUEUE
DEQUEUE
ENQUEUE 1
ENQUEUE 2
DEQUEUE
DEQUEUE
STOP
2
3 101 102 103
3 201 202 203
ENQUEUE 101
ENQUEUE 201
ENQUEUE 102
ENQUEUE 202
ENQUEUE 103
ENQUEUE 203
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
STOP
2
5 259001 259002 259003 259004 259005
6 260001 260002 260003 260004 260005 260006
ENQUEUE 259001
ENQUEUE 260001
ENQUEUE 259002
ENQUEUE 259003
ENQUEUE 259004
ENQUEUE 259005
DEQUEUE
DEQUEUE
ENQUEUE 260002
ENQUEUE 260003
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
STOP
2
2 3 4
1 5
ENQUEUE 3
ENQUEUE 5
ENQUEUE 4
DEQUEUE
DEQUEUE
DEQUEUE
STOP
0
Last edited by brianfry713 on Tue Nov 18, 2014 2:17 am, edited 1 time in total.
Reason: Removed incorrect output
Check input and AC output for thousands of problems on uDebug!

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 540 - Team Queue

Post by lighted » Sat Nov 15, 2014 5:20 pm

For input above my Acc Output. This input is posted by tiendaotd on 2nd page and i have same output.

Code: Select all

Scenario #1
1
2
4
5
6
3

Scenario #2
1
2
4
3
5
6
1

Scenario #3
1
2
3
4

Scenario #4
101
102
103
201
202
203

Scenario #5
259001
259002
259003
259004
259005
260001

Scenario #6
3
4
5

In 1st scenario last dequeued element should be 3 not 1. In 2nd scenario there are 7 dequeue commands so there should be printed 7 elements not 4.
Last edited by lighted on Sat Nov 15, 2014 5:29 pm, edited 1 time in total.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

jddantes
Learning poster
Posts: 73
Joined: Sat Mar 08, 2014 8:55 am

Re: 540 - Team Queue

Post by jddantes » Mon Dec 15, 2014 6:02 pm

Why WA?

Code: Select all

#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int numTeams;
    char cmd[50];
    int caseNum = 0;
    while(scanf("%d", &numTeams)!=EOF){
        if(!numTeams) return 0;
        caseNum++;
        printf("Scenario #%d\n", caseNum);
        vector<int> teamAssignments(1000000, 0);
        list<int> que;
        vector<list<int>::iterator> teamItrs(numTeams+1, que.end()); // Itr to the last member of the team
        for(int i = 1; i<=numTeams; i++){
            int numMems;
            scanf("%d", &numMems);
            for(int j = 0; j<numMems; j++){
                int x;
                scanf("%d", &x);
                teamAssignments[x] = i;
            }
        }



        while(scanf(" %s", cmd)!=EOF){
            if(cmd[0] == 'E'){
                int x;
                scanf("%d", &x);
                int team = teamAssignments[x];

                if(teamItrs[team] == que.end()){
                    que.push_back(x);
                    --teamItrs[team];
                } else {
                    teamItrs[team]++;
                    que.insert(teamItrs[team], x);
                    teamItrs[team]--;
                }


            } else if(cmd[0] =='S'){
                break;
            } else {


                if(que.size()){
                    int x = que.front();
                    int team = teamAssignments[x];
                    cout << x << endl;
                    que.pop_front();

                    if(que.empty() || teamAssignments[que.front()] != team){
                        teamItrs[team] = que.end();
                    } else {
                        teamItrs[team] = que.begin();
                    }



                }
            }
        }

        printf("\n");
    }


    return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 540 - Team Queue

Post by brianfry713 » Mon Dec 15, 2014 11:17 pm

Input:

Code: Select all

1
1 38024
ENQUEUE 38024
DEQUEUE
STOP
9
4 983951 754007 855822 645141
1 787217
4 388527 689431 169250 457811
1 843698
6 739826 278043 27036 707487 529535 112924
10 771676 40561 787525 442318 422941 341902 223735 917857 96272 52491
9 850279 908313 63301 983070 695531 659814 887949 384962 345416
1 834275
5 7316 90453 983509 550704 797940
ENQUEUE 754007
DEQUEUE
ENQUEUE 787217
ENQUEUE 843698
DEQUEUE
DEQUEUE
ENQUEUE 457811
ENQUEUE 983509
DEQUEUE
DEQUEUE
ENQUEUE 908313
ENQUEUE 645141
DEQUEUE
ENQUEUE 27036
ENQUEUE 388527
ENQUEUE 787525
ENQUEUE 341902
DEQUEUE
ENQUEUE 739826
ENQUEUE 52491
ENQUEUE 7316
ENQUEUE 96272
DEQUEUE
ENQUEUE 422941
ENQUEUE 771676
DEQUEUE
ENQUEUE 529535
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 917857
DEQUEUE
ENQUEUE 707487
ENQUEUE 112924
DEQUEUE
ENQUEUE 345416
DEQUEUE
ENQUEUE 442318
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 659814
ENQUEUE 887949
ENQUEUE 223735
ENQUEUE 278043
ENQUEUE 550704
ENQUEUE 983070
ENQUEUE 63301
ENQUEUE 695531
DEQUEUE
ENQUEUE 40561
ENQUEUE 384962
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 797940
ENQUEUE 689431
DEQUEUE
ENQUEUE 850279
DEQUEUE
ENQUEUE 834275
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 855822
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 169250
DEQUEUE
ENQUEUE 90453
DEQUEUE
ENQUEUE 983951
DEQUEUE
DEQUEUE
DEQUEUE
STOP
1
2 5224 268252
ENQUEUE 268252
ENQUEUE 5224
STOP
7
3 290821 701819 226340
9 62213 75810 584724 581602 554505 593613 36534 131029 746761
1 961054
5 995129 821054 4880 372067 737616
1 817300
3 873322 56548 382516
10 839282 307274 327662 646455 9093 70354 870125 71306 146164 454849
ENQUEUE 71306
DEQUEUE
ENQUEUE 62213
DEQUEUE
ENQUEUE 307274
ENQUEUE 372067
ENQUEUE 131029
DEQUEUE
ENQUEUE 995129
DEQUEUE
ENQUEUE 701819
ENQUEUE 9093
ENQUEUE 746761
ENQUEUE 382516
ENQUEUE 821054
DEQUEUE
ENQUEUE 70354
DEQUEUE
ENQUEUE 870125
ENQUEUE 56548
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 839282
ENQUEUE 4880
ENQUEUE 75810
ENQUEUE 146164
ENQUEUE 584724
DEQUEUE
STOP
5
3 823859 996553 137012
6 621284 132281 864494 217217 296810 674915
4 699838 349737 850285 65283
9 674881 904626 545861 823926 622638 142184 451546 520267 414531
2 654062 261768
ENQUEUE 622638
ENQUEUE 904626
DEQUEUE
ENQUEUE 864494
DEQUEUE
DEQUEUE
ENQUEUE 520267
ENQUEUE 142184
ENQUEUE 451546
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 621284
DEQUEUE
ENQUEUE 414531
ENQUEUE 654062
DEQUEUE
ENQUEUE 996553
ENQUEUE 674881
ENQUEUE 132281
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 261768
DEQUEUE
ENQUEUE 217217
DEQUEUE
ENQUEUE 137012
ENQUEUE 674915
ENQUEUE 850285
DEQUEUE
ENQUEUE 823926
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 545861
DEQUEUE
STOP
1
1 748201
STOP
10
3 424799 334670 104831
8 173056 90386 904363 678340 368371 889062 190799 594127
9 161980 804274 735242 22948 136522 305726 135394 3233 558351
7 813321 170355 389649 80631 918556 891003 568932
9 315803 903603 563172 107952 593011 653558 12315 271351 538281
8 462150 132408 273457 140482 453034 525052 163430 589557
1 815176
3 905481 81805 922463
10 471454 519447 510745 362457 604731 969086 194612 24686 48610 302564
9 702168 831231 889049 240450 248961 867552 889210 522418 524386
ENQUEUE 194612
ENQUEUE 903603
ENQUEUE 804274
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 3233
ENQUEUE 305726
ENQUEUE 453034
DEQUEUE
DEQUEUE
ENQUEUE 48610
ENQUEUE 104831
ENQUEUE 161980
ENQUEUE 80631
ENQUEUE 302564
DEQUEUE
ENQUEUE 140482
DEQUEUE
DEQUEUE
ENQUEUE 593011
ENQUEUE 173056
DEQUEUE
DEQUEUE
ENQUEUE 604731
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 22948
ENQUEUE 240450
DEQUEUE
DEQUEUE
ENQUEUE 334670
ENQUEUE 904363
DEQUEUE
ENQUEUE 362457
ENQUEUE 12315
DEQUEUE
ENQUEUE 510745
DEQUEUE
DEQUEUE
ENQUEUE 905481
DEQUEUE
ENQUEUE 589557
ENQUEUE 831231
DEQUEUE
ENQUEUE 522418
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 735242
ENQUEUE 424799
ENQUEUE 248961
ENQUEUE 315803
ENQUEUE 867552
ENQUEUE 563172
ENQUEUE 889062
ENQUEUE 519447
ENQUEUE 678340
DEQUEUE
ENQUEUE 170355
DEQUEUE
ENQUEUE 271351
ENQUEUE 389649
DEQUEUE
ENQUEUE 538281
ENQUEUE 81805
ENQUEUE 889049
DEQUEUE
DEQUEUE
ENQUEUE 594127
DEQUEUE
DEQUEUE
ENQUEUE 525052
ENQUEUE 889210
DEQUEUE
DEQUEUE
ENQUEUE 568932
ENQUEUE 90386
ENQUEUE 462150
DEQUEUE
ENQUEUE 524386
ENQUEUE 813321
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 368371
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 107952
DEQUEUE
ENQUEUE 136522
DEQUEUE
DEQUEUE
ENQUEUE 163430
ENQUEUE 190799
DEQUEUE
DEQUEUE
ENQUEUE 471454
DEQUEUE
ENQUEUE 922463
ENQUEUE 918556
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 815176
DEQUEUE
ENQUEUE 702168
ENQUEUE 132408
ENQUEUE 653558
ENQUEUE 24686
DEQUEUE
ENQUEUE 969086
STOP
3
2 148360 266680
2 51256 88616
5 905410 808426 287615 561525 303982
ENQUEUE 51256
ENQUEUE 148360
ENQUEUE 287615
ENQUEUE 88616
DEQUEUE
ENQUEUE 808426
ENQUEUE 266680
ENQUEUE 303982
ENQUEUE 905410
STOP
2
9 428850 373536 885525 249184 483554 392286 725981 846111 752132
4 755944 322055 894845 537130
ENQUEUE 249184
DEQUEUE
ENQUEUE 322055
ENQUEUE 483554
DEQUEUE
ENQUEUE 755944
DEQUEUE
DEQUEUE
STOP
2
4 318040 634647 658826 642041
10 548714 527566 829033 32268 919853 555014 394731 671985 641170 150676
ENQUEUE 32268
DEQUEUE
ENQUEUE 548714
ENQUEUE 919853
DEQUEUE
ENQUEUE 527566
ENQUEUE 642041
ENQUEUE 829033
DEQUEUE
STOP
3
1 878477
4 502234 922395 737036 534502
9 808403 445586 30585 965925 596262 540977 18292 316772 784738
ENQUEUE 808403
DEQUEUE
ENQUEUE 445586
ENQUEUE 922395
DEQUEUE
DEQUEUE
ENQUEUE 878477
DEQUEUE
ENQUEUE 540977
DEQUEUE
ENQUEUE 18292
DEQUEUE
ENQUEUE 965925
DEQUEUE
ENQUEUE 737036
ENQUEUE 534502
DEQUEUE
DEQUEUE
ENQUEUE 30585
DEQUEUE
ENQUEUE 596262
ENQUEUE 502234
ENQUEUE 316772
ENQUEUE 784738
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
STOP
9
6 839548 115603 381932 148921 555443 365537
8 130158 128315 137978 93138 237472 615009 285490 138594
8 673138 427943 525413 758022 938644 317205 666716 483401
3 979919 620844 997658
7 39833 189275 169527 155436 571207 318448 710879
6 926048 357390 65060 580378 450528 818885
8 252370 957479 748315 441860 385423 273728 199883 840419
5 866599 840172 812928 362870 461016
9 692849 500849 516214 862376 172638 87421 697176 399869 540518
ENQUEUE 317205
ENQUEUE 673138
DEQUEUE
DEQUEUE
ENQUEUE 381932
DEQUEUE
ENQUEUE 580378
ENQUEUE 273728
DEQUEUE
ENQUEUE 130158
ENQUEUE 758022
ENQUEUE 148921
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 525413
ENQUEUE 571207
ENQUEUE 957479
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 155436
DEQUEUE
ENQUEUE 318448
ENQUEUE 115603
ENQUEUE 385423
DEQUEUE
ENQUEUE 555443
DEQUEUE
ENQUEUE 65060
DEQUEUE
DEQUEUE
STOP
4
9 661765 341143 895167 860003 388882 289267 681465 710232 288946
6 755723 745793 228696 294076 100936 381815
5 256149 505024 407538 51851 705609
4 328215 796497 152909 578961
ENQUEUE 796497
ENQUEUE 100936
ENQUEUE 51851
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 288946
STOP
2
7 652298 805136 500919 398092 550184 311347 499028
3 594851 755177 469728
ENQUEUE 652298
STOP
8
6 167948 971834 753484 746909 592813 583449
5 255378 591532 665226 329463 459618
1 692815
2 961739 861465
1 979010
10 397194 290358 274937 361898 885209 546466 831627 920303 386199 6964
9 554147 495151 274362 301056 87964 374163 836553 859695 482048
10 189158 458018 201970 398325 983540 163709 259790 346902 142719 35700
ENQUEUE 971834
ENQUEUE 885209
ENQUEUE 546466
DEQUEUE
DEQUEUE
ENQUEUE 753484
DEQUEUE
DEQUEUE
ENQUEUE 583449
DEQUEUE
ENQUEUE 459618
DEQUEUE
ENQUEUE 87964
ENQUEUE 831627
ENQUEUE 746909
DEQUEUE
ENQUEUE 167948
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 374163
ENQUEUE 920303
ENQUEUE 290358
ENQUEUE 979010
DEQUEUE
ENQUEUE 665226
ENQUEUE 201970
ENQUEUE 274362
DEQUEUE
ENQUEUE 861465
ENQUEUE 386199
DEQUEUE
ENQUEUE 361898
ENQUEUE 482048
ENQUEUE 346902
ENQUEUE 397194
DEQUEUE
DEQUEUE
ENQUEUE 836553
ENQUEUE 255378
ENQUEUE 398325
DEQUEUE
ENQUEUE 495151
DEQUEUE
ENQUEUE 274937
ENQUEUE 259790
DEQUEUE
ENQUEUE 692815
DEQUEUE
ENQUEUE 592813
ENQUEUE 142719
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
STOP
8
9 743566 603447 419784 500316 275040 251325 415152 849254 940936
8 739557 192834 717964 375661 358593 511715 17828 997915
4 703120 554522 50313 607300
3 141319 843750 558
4 535848 912288 523554 795767
6 459690 812435 307127 711016 227587 672733
5 873976 928642 361139 108293 304303
5 620008 838483 233999 16133 541603
ENQUEUE 307127
ENQUEUE 554522
DEQUEUE
ENQUEUE 361139
ENQUEUE 415152
DEQUEUE
ENQUEUE 251325
ENQUEUE 843750
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 500316
DEQUEUE
ENQUEUE 812435
ENQUEUE 375661
DEQUEUE
DEQUEUE
ENQUEUE 849254
ENQUEUE 873976
ENQUEUE 17828
ENQUEUE 672733
ENQUEUE 838483
ENQUEUE 997915
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 16133
ENQUEUE 743566
DEQUEUE
DEQUEUE
ENQUEUE 523554
ENQUEUE 739557
DEQUEUE
DEQUEUE
ENQUEUE 358593
STOP
6
8 947596 919490 816718 893142 964223 204449 347694 170221
5 363452 998827 414282 219831 933072
3 729266 829140 120952
9 843412 704798 362154 420881 365010 951524 865850 854024 89223
8 405840 758680 513455 325330 91751 922950 289554 296200
5 976127 675634 150449 974954 606268
ENQUEUE 922950
DEQUEUE
ENQUEUE 998827
ENQUEUE 675634
ENQUEUE 729266
ENQUEUE 91751
DEQUEUE
ENQUEUE 219831
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 606268
ENQUEUE 296200
DEQUEUE
ENQUEUE 933072
DEQUEUE
ENQUEUE 893142
ENQUEUE 513455
ENQUEUE 363452
DEQUEUE
DEQUEUE
ENQUEUE 816718
DEQUEUE
DEQUEUE
ENQUEUE 420881
DEQUEUE
ENQUEUE 865850
ENQUEUE 854024
DEQUEUE
DEQUEUE
ENQUEUE 89223
ENQUEUE 325330
ENQUEUE 170221
ENQUEUE 758680
DEQUEUE
ENQUEUE 120952
DEQUEUE
ENQUEUE 951524
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 704798
DEQUEUE
ENQUEUE 947596
ENQUEUE 843412
ENQUEUE 362154
DEQUEUE
DEQUEUE
DEQUEUE
ENQUEUE 974954
DEQUEUE
ENQUEUE 365010
DEQUEUE
ENQUEUE 289554
ENQUEUE 829140
DEQUEUE
ENQUEUE 347694
ENQUEUE 405840
DEQUEUE
DEQUEUE
ENQUEUE 150449
DEQUEUE
DEQUEUE
ENQUEUE 964223
DEQUEUE
ENQUEUE 976127
DEQUEUE
ENQUEUE 204449
ENQUEUE 414282
ENQUEUE 919490
DEQUEUE
DEQUEUE
DEQUEUE
STOP
8
9 37384 452922 485537 560398 765267 887570 788836 975098 610852
7 964629 76740 907534 533392 706329 251070 933554
10 872051 216374 483257 369473 92086 641839 114268 35855 944261 4559
1 474541
9 205754 927463 543677 282504 692730 431248 587692 184181 558452
2 148810 635192
6 198555 857873 147096 132109 738124 535499
4 221382 904972 956922 379573
ENQUEUE 132109
ENQUEUE 944261
STOP
2
9 81940 915957 242191 141969 198461 451274 573217 302505 635455
2 290996 300617
ENQUEUE 198461
DEQUEUE
ENQUEUE 573217
DEQUEUE
ENQUEUE 915957
ENQUEUE 141969
ENQUEUE 290996
ENQUEUE 302505
DEQUEUE
DEQUEUE
ENQUEUE 242191
ENQUEUE 635455
ENQUEUE 300617
ENQUEUE 451274
ENQUEUE 81940
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
STOP
2
3 246518 662523 601460
7 339331 717829 405746 673577 201021 382581 403387
ENQUEUE 339331
ENQUEUE 662523
DEQUEUE
ENQUEUE 717829
DEQUEUE
DEQUEUE
ENQUEUE 673577
DEQUEUE
ENQUEUE 601460
DEQUEUE
ENQUEUE 382581
DEQUEUE
ENQUEUE 246518
ENQUEUE 201021
DEQUEUE
ENQUEUE 403387
ENQUEUE 405746
STOP
0
AC output:

Code: Select all

Scenario #1
38024

Scenario #2
754007
787217
843698
457811
983509
908313
645141
27036
739826
388527
787525
341902
52491
96272
422941
771676
917857
442318
7316
550704
529535
707487
112924
278043
345416
659814
887949
983070
63301
695531
384962
850279
223735
40561
797940
689431
169250
834275
855822
983951

Scenario #3

Scenario #4
71306
62213
307274
372067
995129
821054
131029
746761
701819
9093
70354

Scenario #5
622638
904626
864494
520267
142184
451546
621284
414531
654062
996553
674881
132281
261768
217217
137012
674915
850285
823926
545861

Scenario #6

Scenario #7
194612
903603
804274
3233
305726
453034
48610
302564
104831
161980
80631
140482
593011
173056
604731
22948
240450
334670
904363
362457
510745
12315
905481
589557
831231
522418
248961
867552
735242
424799
315803
563172
271351
538281
889062
678340
594127
90386
519447
170355
389649
568932
813321
81805
889049
889210
524386
525052
462150
163430
368371
190799
107952
136522
471454
922463
918556

Scenario #8
51256

Scenario #9
249184
322055
483554
755944

Scenario #10
32268
548714
919853

Scenario #11
808403
445586
922395
878477
540977
18292
965925
737036
534502
30585
596262
316772
784738
502234

Scenario #12
317205
673138
381932
580378
273728
130158
758022
148921
525413
571207
957479
155436
318448
115603
555443

Scenario #13
796497
100936
51851

Scenario #14

Scenario #15
971834
885209
546466
753484
583449
459618
87964
831627
746909
167948
374163
920303
290358
386199
361898
397194
979010
665226
255378
201970
346902
398325
259790
142719

Scenario #16
307127
554522
361139
415152
251325
843750
500316
812435
375661
17828
997915
849254
743566
873976
672733

Scenario #17
922950
998827
675634
729266
91751
219831
606268
296200
933072
363452
893142
816718
513455
420881
865850
854024
89223
325330
758680
170221
120952
951524
704798
947596
843412
362154
974954
365010
289554
829140
347694
405840
150449
964223
976127
204449
919490
414282

Scenario #18

Scenario #19
198461
573217
915957
141969
302505
242191
635455
451274
81940
290996
300617

Scenario #20
339331
662523
717829
673577
601460
382581
246518

Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 5 (500-599)”