Service Center
来源:互联网 发布:宿舍用品淘宝店 编辑:程序博客网 时间:2024/05/18 03:07
Electronics Service Center was visited by a total of N customers
Service Center has a total of M employees.
To those employees that customers visit in order to get in line, line stands, if the services of no n-employee immediately to receive services.
Customers get tickets which are labeled from 1 to N by service center and return the tickets when their service is finished.
Write a program to check if the sequence of tickets is possible after finishing service for all customers.
For example, if the number of customers (N) is 5, the number of total employees (M) is 3,
1-2-3-4-5, 1-3-5-2-4, 3-4-1-5-2 is possible, whereas 4-1-2-3-5, 3-5-4-2-1 is impossible.
[Input]
There can be more than one test case in the input.
The first line has T, the number of test cases.
Then the totally T test cases are provided in the following lines.
In each test case, the first line has three integer; the number of customers (N), the number of employees (M), the number of sequence(S) to be verified.
For next S lines, each contains the sequence of retuning tickets.
[Output]
For each test case, you should print your answer in one line.
Print “1” if the sequence is possible or “0” if the sequence is impossible.
[Input Example]
2
5 3 5
1 2 3 4 5
1 3 5 2 4
3 4 1 5 2
4 1 2 3 5
3 5 4 2 1
5 5 3
3 4 1 5 2
4 1 2 3 5
3 5 4 2 1
[Output Example]
11100
111
#include <stdio.h>int N, M, P;int data[11][1001];int answer[11][11];int main(void) {int test_case;int T;setbuf(stdout, NULL);scanf("%d", &T);for (test_case = 0; test_case < T; test_case++) {int i, j;scanf("%d %d %d", &N, &M, &P);for (i = 1; i <= P; i++) {for (j = 1; j <= N; j++) {scanf("%d", &data[i][j]);}}for (i = 1; i <= P; i++) {answer[test_case][i] = 1; //set value 1 instead of 0}for (i = 1; i <= P; i++) {int maxCustomerN = M;for (j = 1; j <= N; j++) {if (data[i][j] > maxCustomerN) {answer[test_case][i] = 0;break;}maxCustomerN++;}}// Print the answer to standard output(screen).for (i = 1; i <= P; i++) {printf("%d", answer[test_case][i]);}printf("\n");}return 0; //Your program should return 0 on normal termination.}
- Service Center
- GIS Service Center – Download
- 【蓝牙】Apple Notification Center Service (ANCS) Specification
- Center
- owb基本概念之Workspaces、Repository和Control Center Service
- OM Console Issue: The System Center Data Access Service service terminated unexpectedly
- 《二》CC2540和CC2541上实现ANCS(Apple Notification Center Service)
- Documentation Center
- UNIX-CENTER
- String#center
- CALL CENTER
- unix-center
- FortiGuard Center
- Business Center
- Data center
- float:center
- Game Center
- center display
- ASP.NET页面之间传值的五种常用方法
- 多表关联删除
- 权限
- linux历史
- Java/JSP中文乱码问题解决心得
- Service Center
- 久违的孟庭苇
- YUV(二)-YUV格式转换缩放
- ubuntu13.10 kvm 虚拟机的安装---命令行下
- Hive+GenericUDF示例二
- 获取窗口的大小
- YUV(三)-YUV420_to_RGB24 算法
- 【Java TCP/IP Soket】— 消息边界的问题解决
- 记录下linux下find命令查找的常用用法