Submission #35214

# Submission time Handle Problem Language Result Execution time Memory
35214 2017-11-19T04:27:33 Z wan2000 스파이 (JOI13_spy) C++14
0 / 100
0 ms 18004 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2005;

int n, m, tin[2][N], tout[2][N], counter, D[N][N];
vector<int> Adj[2][N];

void DFS(int u, int type){
    tin[type][u] = counter++;
    for(int i = 0; i < (int)Adj[type][u].size(); i++){
        int v = Adj[type][u][i];
        DFS(v,type);
    }
    tout[type][u] = counter;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin>>n>>m;
    for(int i = 1; i <= n; i++){
        int x, y;
        cin>>x>>y;
        Adj[0][x].push_back(i);
        Adj[1][y].push_back(i);
    }
    counter = 0;
    DFS(0,0);
    counter = 0;
    DFS(0,1);
    for(int i = 1; i <= m; i++){
        int a, b;
        cin>>a>>b;
        int x = tin[0][a];
        int u = tout[0][a];
        int y = tin[1][b];
        int v = tout[1][b];
        D[x][y]++;
        D[x][v]--;
        D[u][y]--;
        D[u][v]++;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            D[i][j] += D[i-1][j]+D[i][j-1]-D[i-1][j-1];
        }
    }
    for(int i = 1; i <= n; i++){
        //cout<<D[tin[0][i]][tin[1][i]]<<'\n';
        printf("%d\n", D[tin[0][i]][tin[1][i]]);
    }
    return 0;
}

Compilation message

spy.cpp: In function 'int main()':
spy.cpp:22:37: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt", "r", stdin);
                                     ^
spy.cpp:23:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("output.txt", "w", stdout);
                                       ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 18004 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 18004 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 18004 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -