Submission #910182

# Submission time Handle Problem Language Result Execution time Memory
910182 2024-01-18T01:10:49 Z vjudge1 Amusement Park (JOI17_amusement_park) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
#define f first
#define s second
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ENDL '\n'
#define fore(a,b,c) for(lli a = (b), fgh = (c); a < fgh; a ++)
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const lli NN = 1e4 + 5;
lli valval[NN];
vi adjadj[NN];
int nn, mm, tt, pp, pos, vv;
lli xx, co = 0;

bool bs(lli val, vi &v){
    sort(all(v));
    lli pos = -1, s = sz(v);
    while(s){
        while(pos + s < sz(v) and v[pos + s] < val) pos += s;
        s /= 2;
    }
    pos ++;
    if(pos >= sz(v) or v[pos] != val) return false;
    return true;
}

void Fwa(lli i){
    cout << "WA " << i << ENDL;
}

void MessageBoard(int attr, int msg){
    if(attr < 0 or nn <= attr or valval[attr] != 0) Fwa(1);
    valval[attr] = msg + 1;
    co ++;
}

int Move(int dest){
    if(!bs(dest, adjadj[pos])) Fwa(2);
    pos = dest;
    return valval[pos] - 1;
}

void Joi(int N, int M, int A[], int B[], lli X, int T){
    fore(i,0,60){
        MessageBoard(i,X % 2);
        X /= 2;
    }
    fore(i,60,N){
        MessageBoard(i,0);
    }
}

const lli N = 1e4 + 5;
vi adj[N];
lli val[N];
bool vis[N];

void dfs(lli p, lli org, lli ant){
    if(p != org) val[p] = Move(p);
    for(auto i: adj[p]){
        if(i == p or vis[i] == true) continue;
        vis[i] = true;
        dfs(i, org, p);
    }
    if(ant != -1) Move(ant);
}

lli Ioi(int N, int M, int A[], int B[], int P, int V, int T){
    fore(i,0,M){
        adj[A[i]].pb(B[i]);
        adj[B[i]].pb(A[i]);
    }
    vis[P] = true;
    dfs(P,P,-1);
    lli x = 1, ans = 0;
    fore(i,0,60){
        ans += val[i] * x;
        x *= 2;
    }
    return ans;
}

int main(){ _
    cin >> nn >> mm;
    int aa[mm], bb[mm];
    fore(i,0,mm){
        lli ap, bp; cin >> ap >> bp;
        aa[i] = ap, bb[i] = bp;
        adjadj[ap].pb(bp);
        adjadj[bp].pb(ap);
    }
    cin >> xx >> pp >> vv >> tt;
    pos = pp;
    Joi(nn, mm, aa, bb, xx, tt);
    if(co != nn) Fwa(3);
    lli gans = Ioi(nn, mm, aa, bb, pp, valval[pp] - 1, tt);
    if(gans == xx) cout << "ACC" << ENDL;
    else cout << "WA" << ENDL;
    cout << gans << ENDL;
    fore(i,0,60) cout << valval[i] << ' '; cout << ENDL;
    fore(i,0,60) cout << val[i] << ' '; cout << ENDL;
    // fore(i,0,5){ for(auto j: adj[i])  cout << j << ' '; cout << ENDL; }
    return 0;
}



    

Compilation message

Joi.cpp: In function 'bool bs(lli, vi&)':
Joi.cpp:27:23: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         while(pos + s < sz(v) and v[pos + s] < val) pos += s;
      |                       ^
Joi.cpp:31:12: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if(pos >= sz(v) or v[pos] != val) return false;
      |            ^
Joi.cpp: In function 'int main()':
Joi.cpp:14:21: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 | #define fore(a,b,c) for(lli a = (b), fgh = (c); a < fgh; a ++)
      |                     ^~~
Joi.cpp:108:5: note: in expansion of macro 'fore'
  108 |     fore(i,0,60) cout << valval[i] << ' '; cout << ENDL;
      |     ^~~~
Joi.cpp:108:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  108 |     fore(i,0,60) cout << valval[i] << ' '; cout << ENDL;
      |                                            ^~~~
Joi.cpp:14:21: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 | #define fore(a,b,c) for(lli a = (b), fgh = (c); a < fgh; a ++)
      |                     ^~~
Joi.cpp:109:5: note: in expansion of macro 'fore'
  109 |     fore(i,0,60) cout << val[i] << ' '; cout << ENDL;
      |     ^~~~
Joi.cpp:109:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  109 |     fore(i,0,60) cout << val[i] << ' '; cout << ENDL;
      |                                         ^~~~
/usr/bin/ld: /tmp/ccPkczRT.o: in function `MessageBoard(int, int)':
grader_joi.cpp:(.text+0x4e0): multiple definition of `MessageBoard(int, int)'; /tmp/ccYh1ovW.o:Joi.cpp:(.text+0x610): first defined here
/usr/bin/ld: /tmp/ccPkczRT.o: in function `main':
grader_joi.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccYh1ovW.o:Joi.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/cc19hFiF.o: in function `main':
grader_ioi.cpp:(.text.startup+0x3f2): undefined reference to `Ioi(int, int, int*, int*, int, int, int)'
collect2: error: ld returned 1 exit status