답안 #713647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713647 2023-03-22T18:35:25 Z aedmhsn 연결리스트 수사하기 (NOI12_forensic) C++17
5 / 25
1000 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
 
#define A first
#define B second
#define MP make_pair
#define ms(a, x) memset(a, x, sizeof(a)) 
 
#define boost() ios_base::sync_with_stdio(false); cin.tie(0)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pld;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
 
const int mxN=2e4+5;

vector <int> a(mxN);


 
int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];
    int ans1=0;
    for(int i=0; i<n; i++){
        int before=a[i];
        for(int j=-1; j<n; j++){
            a[i]=j;
            bool path1[mxN]={};
            int lnode=0, ans=0;
            while(lnode != -1 && !path1[lnode]){
                path1[lnode]=1;
                ans++;
                lnode = a[lnode];
            }
            if(lnode == -1)
                ans1 = max(ans, ans1);
        }
        a[i] = before;
    }
    cout << ans1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1076 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1051 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -