Submission #1037511

#TimeUsernameProblemLanguageResultExecution timeMemory
1037511sleepntsheepToy Train (IOI17_train)C++17
0 / 100
4 ms980 KiB
#include "train.h"

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
    int n = a.size();
    int m = u.size();

    std::vector<int> loop(n);
    for (int i = 0; i < m; ++i)
        if (u[i] == v[i])
            loop[u[i]] = 1;

	std::vector<int> res(a.size());

    int are = 0, bre = 0;

    if (r[n-1])
        res[n-1] = 1, are = 1;
    else
        bre = 1;

    for (int i = n - 2; i >= 0; --i) {
        if (loop[i]) {
            if (r[i]) {
                res[i] = 1;
            } else {
                res[i] = 0;
            }
        } else {
            res[i] = res[i + 1];
        }
    }
	return res;
}

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:8:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    8 |     for (int i = 0; i < m; ++i)
      |     ^~~
train.cpp:12:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   12 |  std::vector<int> res(a.size());
      |  ^~~
train.cpp:14:9: warning: variable 'are' set but not used [-Wunused-but-set-variable]
   14 |     int are = 0, bre = 0;
      |         ^~~
train.cpp:14:18: warning: variable 'bre' set but not used [-Wunused-but-set-variable]
   14 |     int are = 0, bre = 0;
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...