답안 #143107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143107 2019-08-13T01:35:05 Z daniel920712 Arranging Shoes (IOI19_shoes) C++14
10 / 100
1000 ms 1912 KB
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;
long long count_swaps(std::vector<int> S)
{
    vector<int> S1;
    long long ans1=0,ans2=0,N=S.size(),i,j,k;
    int t;
    for(i=0;i<N/2;i++)
    {
        for(j=2*i;j<N;j++)
        {
            if(S[j]<0)
            {
                t=0-S[j];
                for(k=j;k>2*i;k--)
                {
                    ans1++;
                    swap(S[k],S[k-1]);
                }
                break;
            }
        }
        for(j=2*i+1;j<N;j++)
        {
            if(S[j]==t)
            {
                for(k=j;k>2*i+1;k--)
                {
                    ans1++;
                    swap(S[k],S[k-1]);
                }
                break;
            }
        }

    }


    return ans1;
}

Compilation message

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:9:22: warning: unused variable 'ans2' [-Wunused-variable]
     long long ans1=0,ans2=0,N=S.size(),i,j,k;
                      ^~~~
shoes.cpp:28:13: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(S[j]==t)
             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 252 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 5 ms 504 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 43 ms 1888 KB Output is correct
23 Correct 27 ms 1912 KB Output is correct
24 Correct 30 ms 1912 KB Output is correct
25 Execution timed out 1078 ms 1912 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Execution timed out 1076 ms 1912 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 252 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 252 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Halted 0 ms 0 KB -