Submission #934085

#TimeUsernameProblemLanguageResultExecution timeMemory
934085sopaconkCity (JOI17_city)C++17
Compilation error
0 ms0 KiB
#include "Encoder.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define deb(x) ; using lli=long long int; static lli aux=0; void dfs(int n , int par, vector<vector<int>> &adj, vector<pair<lli,lli>> &range ){ lli ini=aux; aux++; for(int x: adj[n]){ if(x==par) continue; dfs(x, n, adj, range); } lli fin=aux; range[n]={ini, fin}; } void Encode(int N, int A[], int B[]) { vector<vector<int>> adj (N); for(int i=0; i<N-1; ++i){ adj[A[i]].pb(B[i]); adj[B[i]].pb(A[i]); } vector<pair<lli,lli>> range (N); dfs(0,-1,adj, range); for (int i = 0; i < N; ++i) { lli ini=range[i].first; lli fin=range[i].second; lli dif=fin-ini; dif/=2; Code(i, ini*250000+dif); } }
#include <stdio.h> #include <stdlib.h> #define NMAX 250000 #define QMAX 250000 #define CODEMAX ((1LL << 60LL) - 1) void Encode(int N, int A[], int B[]); void InitDevice(); int Answer(long long S, long long T); static int N, Q, A[NMAX], B[NMAX], X[QMAX], Y[QMAX], expected[QMAX]; static long long given_code[NMAX]; static int ans[QMAX]; void WrongAnswer(int e) { printf("Wrong Answer[%d]\n", e); exit(1); } void Code(int city, long long code) { if (!(0 <= city && city <= N - 1)) { WrongAnswer(1); } if (given_code[city] != -1) { WrongAnswer(2); } if (!(0 <= code && code <= CODEMAX)) { WrongAnswer(3); } given_code[city] = code; } int main(void) { int i; long long max_code; scanf("%d%d", &N, &Q); for (i = 0; i < N - 1; ++i) { scanf("%d%d", &(A[i]), &(B[i])); } for (i = 0; i < Q; ++i) { scanf("%d%d%d", &(X[i]), &(Y[i]), &(expected[i])); } for (i = 0; i < N; ++i) given_code[i] = -1; Encode(N, A, B); for (i = 0; i < N; ++i) { if (given_code[i] == -1) { WrongAnswer(4); } } InitDevice(); for (i = 0; i < Q; ++i) { ans[i] = Answer(given_code[X[i]], given_code[Y[i]]); if (!(0 <= ans[i] && ans[i] <= 2)) { WrongAnswer(5); } if (ans[i] != expected[i]) { WrongAnswer(6); } } max_code = 0; for (i = 0; i < N; ++i) { if (max_code < given_code[i]) { max_code = given_code[i]; } } printf("Accepted : max_code=%lld\n", max_code); return 0; }

Compilation message (stderr)

Device.cpp: In function 'int main()':
Device.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  scanf("%d%d", &N, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~
Device.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d%d", &(A[i]), &(B[i]));
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Device.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   scanf("%d%d%d", &(X[i]), &(Y[i]), &(expected[i]));
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccyJAD4L.o: in function `WrongAnswer(int)':
grader_device.cpp:(.text+0x0): multiple definition of `WrongAnswer(int)'; /tmp/ccM8C55I.o:Device.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccyJAD4L.o: in function `Code(int, long long)':
grader_device.cpp:(.text+0x60): multiple definition of `Code(int, long long)'; /tmp/ccM8C55I.o:Device.cpp:(.text+0x30): first defined here
/usr/bin/ld: /tmp/ccyJAD4L.o: in function `main':
grader_device.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccM8C55I.o:Device.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccM8C55I.o: in function `main':
Device.cpp:(.text.startup+0x103): undefined reference to `Encode(int, int*, int*)'
/usr/bin/ld: Device.cpp:(.text.startup+0x13c): undefined reference to `InitDevice()'
/usr/bin/ld: Device.cpp:(.text.startup+0x182): undefined reference to `Answer(long long, long long)'
/usr/bin/ld: /tmp/ccyJAD4L.o: in function `main':
grader_device.cpp:(.text.startup+0xf8): undefined reference to `InitDevice()'
/usr/bin/ld: grader_device.cpp:(.text.startup+0x19b): undefined reference to `Answer(long long, long long)'
collect2: error: ld returned 1 exit status