Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.3 kB
11
Indexable
Never
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Solution
{
	private static BufferedReader br;
	private static UserSolution usersolution = new UserSolution();

	private final static int CMD_INIT = 100;
	private final static int CMD_SHARE = 200;
	private final static int CMD_REQUEST = 300;
	private final static int CMD_COMPLETE = 400;

	private static boolean run() throws Exception {
		int[] u = new int[200];
		int[] v = new int[200];
		int[] bandwidth = new int[200];
		char[] filename = new char[10];

		StringTokenizer stdin = new StringTokenizer(br.readLine(), " ");

		int query_num = Integer.parseInt(stdin.nextToken());

		boolean ok = false;

		for (int q = 0; q < query_num; q++) {
			stdin = new StringTokenizer(br.readLine(), " ");

			int query = Integer.parseInt(stdin.nextToken());

			if (query == CMD_INIT) {
				int N = Integer.parseInt(stdin.nextToken());
				for(int i = 0; i < N-1; i++)
					u[i] = Integer.parseInt(stdin.nextToken());
				for(int i = 0; i < N-1; i++)
					v[i] = Integer.parseInt(stdin.nextToken());
				for(int i = 0; i < N-1; i++)
					bandwidth[i] = Integer.parseInt(stdin.nextToken());

				usersolution.init(N, u, v, bandwidth);
				ok = true;
			} else if (query == CMD_SHARE) {
				int uid = Integer.parseInt(stdin.nextToken());
				String inputStr = stdin.nextToken();
				for(int k = 0; k < inputStr.length(); ++k)
					filename[k] = inputStr.charAt(k);
				filename[inputStr.length()] = '\0';
				int filesize = Integer.parseInt(stdin.nextToken());

				int ret = usersolution.share(uid, filename, filesize);
				int ans = Integer.parseInt(stdin.nextToken());
				if(ret != ans)
					ok = false;
			} else if (query == CMD_REQUEST) {
				int uid = Integer.parseInt(stdin.nextToken());
				String inputStr = stdin.nextToken();
				for(int k = 0; k < inputStr.length(); ++k)
					filename[k] = inputStr.charAt(k);
				filename[inputStr.length()] = '\0';
				int tid = Integer.parseInt(stdin.nextToken());

				int ret = usersolution.request(uid, filename, tid);
				int ans = Integer.parseInt(stdin.nextToken());
				if(ret != ans)
					ok = false;
			} else if (query == CMD_COMPLETE) {
				int tid = Integer.parseInt(stdin.nextToken());

				int ret = usersolution.complete(tid);
				int ans = Integer.parseInt(stdin.nextToken());
				if(ret != ans)
					ok = false;
			}
		}

		return ok;
	}

	public static void main(String[] args) throws Exception {
		int T, MARK;

		//System.setIn(new java.io.FileInputStream("res/sample_input.txt"));
		br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer stinit = new StringTokenizer(br.readLine(), " ");
		T = Integer.parseInt(stinit.nextToken());
		MARK = Integer.parseInt(stinit.nextToken());

		for (int tc = 1; tc <= T; tc++) {
			int score = run() ? MARK : 0;
			System.out.println("#" + tc + " " + score);
		}

		br.close();
	}
}

class UserSolution
{
	public void init(int N, int mUID1[], int mUID2[], int mBandwidth[])
	{

	}

	public int share(int mUID, char mFilename[], int mFilesize)
	{
		return -2;
	}

	public int request(int mUID, char mFilename[], int mTID)
	{
		return -2;
	}

	public int complete(int mTID)
	{
		return -2;
	}
}
Leave a Comment