Submission #15452

# Submission time Handle Problem Language Result Execution time Memory
15452 2015-07-12T07:54:09 Z xhae 로봇 심판의 님 게임 (kriii3_F) C++14
28 / 79
15 ms 5628 KB
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int main()
{
  int N, M, K;
  cin >> N >> M >> K;

  vector<int> P(N), Q(M), cnt(K);
  for (int i=0; i<N; i++) cin >> P[i];
  for (int i=0; i<M; i++) cin >> Q[i];
  for (int i=0; i<K; i++) cin >> cnt[i];

  vector<int> S(1000001);
  for (int i=0; i<N; i++)
    for (int j=P[i]; j<=1000000; j+=P[i])
      S[j] --;

  for (int i=0; i<M; i++)
    for (int j=Q[i]; j<=1000000; j+=Q[i])
      if (S[j] >= 0) S[j] ++;

  int cc = 0;
  for (int i=1; i<=1000000; i++)
    if (S[i] > 0) {
      cc ++;
      S[i] = cc;
    } else S[i] = 0;

  int xx = 0;
  for (int i=0; i<K; i++) xx ^= S[cnt[i]];

  for (int i=0; i<K; i++) {
    int target = S[cnt[i]] ^ xx;

    if (S[cnt[i]] > 0 && target < S[cnt[i]]) {
      int dd = 0, res = 0;
      for (int j=0; j<cnt[i]; j++) {
        if (S[j] == target) {
          res = cnt[i] - j;
          dd ++;
        }
      }
      cout << dd << " " << res << endl;
    } else cout << "0 0" << endl;
  }
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 5628 KB Output is correct
2 Correct 5 ms 5628 KB Output is correct
3 Correct 4 ms 5628 KB Output is correct
4 Correct 10 ms 5628 KB Output is correct
5 Correct 15 ms 5628 KB Output is correct
6 Correct 7 ms 5628 KB Output is correct
7 Correct 5 ms 5628 KB Output is correct
8 Correct 2 ms 5628 KB Output is correct
9 Correct 9 ms 5628 KB Output is correct
10 Correct 6 ms 5628 KB Output is correct
11 Correct 0 ms 5628 KB Output is correct
12 Correct 6 ms 5628 KB Output is correct
13 Correct 9 ms 5628 KB Output is correct
14 Correct 4 ms 5628 KB Output is correct
15 Correct 9 ms 5628 KB Output is correct
16 Correct 15 ms 5628 KB Output is correct
17 Correct 9 ms 5628 KB Output is correct
18 Correct 12 ms 5628 KB Output is correct
19 Correct 4 ms 5628 KB Output is correct
20 Correct 10 ms 5628 KB Output is correct
21 Correct 12 ms 5628 KB Output is correct
22 Correct 10 ms 5628 KB Output is correct
23 Correct 9 ms 5628 KB Output is correct
24 Correct 10 ms 5628 KB Output is correct
25 Correct 3 ms 5628 KB Output is correct
26 Correct 0 ms 5628 KB Output is correct
27 Correct 15 ms 5628 KB Output is correct
28 Correct 4 ms 5628 KB Output is correct
29 Correct 6 ms 5628 KB Output is correct
30 Correct 5 ms 5628 KB Output is correct
31 Correct 3 ms 5628 KB Output is correct
32 Correct 10 ms 5628 KB Output is correct
33 Correct 10 ms 5628 KB Output is correct
34 Correct 5 ms 5628 KB Output is correct
35 Correct 0 ms 5628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5624 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -