QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#65633#2479. Rescue MissionUBB_Zalau00#WA 17ms3820kbC++14545b2022-12-02 16:20:512022-12-02 16:20:54

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-02 16:20:54]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3820kb
  • [2022-12-02 16:20:51]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main(){

  int n;

  scanf("%d", &n);

  vector<int> sum(n + 1);

  for(int i = 1;i <= n;i++){
    scanf("%d", &sum[i]);
    sum[i] += sum[i - 1];
    sum[i] %= 10;
  }

  vector<int> last(10, -1);

  last[0] = 0;
  vector<int> answer(n + 1, -1);
  for(int i = n;i;i--){
    last[sum[i]] = i;
    if(last[sum[i - 1]] != -1){
      answer[i] = last[sum[i - 1]] - i + 1;
    }
  }

  for(int i = 1;i <= n;i++){
    printf("%d ", answer[i]);
  }

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3556kb

input:

5
0 2 4 6 8

output:

1 4 2 -1 -1 

result:

ok single line: '1 4 2 -1 -1 '

Test #2:

score: -100
Wrong Answer
time: 17ms
memory: 3820kb

input:

100000
0 7 9 5 5 5 7 3 5 5 3 6 2 0 3 4 2 8 1 2 0 3 2 4 3 8 7 8 4 7 5 9 9 4 3 3 1 5 6 5 6 4 9 9 5 2 5 3 0 2 0 8 7 8 3 9 1 9 4 4 1 2 4 0 3 1 9 0 3 8 1 6 0 8 5 5 9 2 7 5 8 5 2 0 3 2 3 5 5 9 2 0 0 9 5 9 2 0 5 3 0 3 3 0 5 2 7 4 9 9 8 8 3 0 4 9 3 8 9 9 4 6 4 1 5 4 2 8 4 0 9 0 5 7 8 1 9 9 6 6 5 2 8 2 4 4 8...

output:

1 11 21 2 2 4 2 23 2 35 7 14 7 1 6 7 2 7 9 60 1 5 12 5 5 16 6 28 10 4 5 8 5 3 46 5 9 22 5 7 2 31 5 18 10 3 4 6 1 3 1 12 25 3 6 2 2 5 13 15 5 5 7 1 14 2 4 1 40 22 5 11 1 24 2 15 20 50 3 4 6 4 5 1 28 3 16 2 7 5 25 1 1 6 9 10 4 1 12 18 1 6 4 1 37 8 3 4 8 11 24 20 12 1 15 3 3 4 15 28 2 2 3 3 18 24 2 11 ...

result:

wrong answer 1st lines differ - expected: '1 11 21 2 2 4 2 23 2 35 7 14 7...1 5 5 5 5 -1 4 -1 -1 -1 -1 1 -1', found: '1 11 21 2 2 4 2 23 2 35 7 14 7... 5 5 -1 4 -1 -1 -99996 -1 1 -1 '