답안 #778467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
778467 2023-07-10T10:48:28 Z I_Love_EliskaM_ 장난감 기차 (IOI17_train) C++14
0 / 100
5 ms 724 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define ll long long

const int N=5555;
vector<int> adj[N];
int vis[N];

vector<int> p1(vector<int>a,vector<int>r,vector<int>u,vector<int>v) {
	int n=a.size(), m=u.size();
	vector<int> s(n);
	vector<int> f(n);
	vector<int> ans(n);
	forn(i,m) if (u[i]==v[i]) s[u[i]]=1;
	forn(i,m) if (u[i]!=v[i]) f[u[i]]=1;
	int now=0;
	for (int i=n-1; i>=0; --i) {
		if (s[i]) {
			if (now) {
				if (!a[i]) {
					if (!r[i]) now=1;
				} else {
					if (f[i]) now=1;
					else now = r[i];
				}
			} else {
				if (a[i]) {
					if (r[i]) now=1;
				} else {
					if (f[i]) now=0;
					else now = r[i];
				}
			}
		}
		ans[i]=now;
	}
	return ans;
}

vector<int> p3(vector<int>a,vector<int>r,vector<int>u,vector<int>v) {
	int n=a.size(), m=u.size();
	vector<int> ans(n);
	vector<int> ok(n);
}

vector<int> p4(vector<int>a,vector<int>r,vector<int>u,vector<int>v) {
	int n=a.size(), m=u.size();
	vector<int> s(n);
	vector<int> ans(n);
	forn(i,m) if (u[i]==v[i]) s[i]=1;
	int now;
	for (int i=n-1; i>=0; --i) {
		if (s[i]) now=a[i];
		ans[i]=now;
	}
	return ans;
}

vector<int> who_wins(vector<int>a,vector<int>r,vector<int>u,vector<int>v) {

	int n=a.size(), m=u.size();
	int z=1;
	forn(i,m) z&=(u[i]==v[i]) || (v[i]==(u[i]+1));
	if (z) {
		return p1(a,r,u,v);
	}
	exit(1);
	return vector<int>(n,0);
	z=1;
	forn(i,n) z&=a[i];
	if (z) return p3(a,r,u,v);
	forn(i,n) z|=a[i];
	if (!z) return p4(a,r,u,v);

}

Compilation message

train.cpp: In function 'std::vector<int> p3(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:44:18: warning: unused variable 'm' [-Wunused-variable]
   44 |  int n=a.size(), m=u.size();
      |                  ^
train.cpp:47:1: warning: no return statement in function returning non-void [-Wreturn-type]
   47 | }
      | ^
train.cpp: In function 'std::vector<int> p4(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:57:9: warning: 'now' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |   ans[i]=now;
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 724 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 716 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 724 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -