Submission #1151635
Source Code Expand
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
namespace std {
bool operator<(const P& a, const P& b) {
return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}
}
struct INFO {
int from, to, f;
INFO(int a, int b, int c) : from(a), to(b), f(c) {}
};
signed main() {
int n; cin >> n;
map<string, int> m;
rep(i,0,n) {
string s; cin >> s;
m[s] = i;
}
vector<INFO> v;
vector< pair<string, int> > vs;
int rank[25] = {};
rep(i,0,n) {
char name[25], gorb[10];
scanf("%s is a %s venturer.", name, gorb);
string NAME, GORB;
NAME = name, GORB = gorb;
vs.pb( make_pair(NAME, i) );
int j = m[ NAME ];
if(GORB == "good") v.pb(INFO(i, j, 1));
else v.pb(INFO(i, j, 0));
}
sort(vs.begin(), vs.end());
rep(i,0,n) {
rank[vs[i].sc] = i;
}
int ma = -1, temp = INF;
rep(i,0,1 << n) {
bool ok = true;
// printf("debug: i = %lld\n", i);
rep(j,0,n) {
int x = v[j].from, y = v[j].to;
bool jfrom = i >> x, jto = i >> y;
if(jfrom) {
// true talking
if(!jto && v[j].f) ok = false;
if(jto && !v[j].f) ok = false;
}
else {
// false talking
if(jto && v[j].f) ok = false;
if(!jto && !v[j].f) ok = false;
}
}
if(ok) {
int sz = __builtin_popcount(i);
if(sz < ma) continue;
int r = 0;
rep(j,0,n) {
if(i >> j & 1) r += 1 << rank[j];
}
if(sz == ma && r < temp) temp = r;
else if(sz > ma) {
ma = sz;
temp = r;
}
}
}
if(ma == -1) cout << "No answers" << endl;
else {
rep(i,0,n) {
int idx = vs[i].sc;
if(temp >> idx & 1) cout << vs[i].fr << endl;
}
}
return 0;
}
Submission Info
Submission Time
2017-03-09 00:10:53+0900
Task
C - 酒場の冒険者たち
User
tsutaj
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
3346 Byte
Status
WA
Exec Time
56 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:82:50: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s is a %s venturer.", name, gorb);
^
Judge Result
Set Name
All
Score / Max Score
0 / 100
Status
Set Name
Test Cases
All
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_max_00.txt, 01_max_01.txt, 05_corner_00.txt, 05_corner_01.txt, 05_corner_02.txt, 10_min_00.txt, 10_min_01.txt, 10_min_02.txt, 10_wrong_answer_00.txt, 20_max_00.txt, 20_max_01.txt, 20_max_02.txt, 90_random_00.txt, 90_random_01.txt, 90_random_02.txt, 90_random_03.txt, 90_random_04.txt, 90_random_05.txt, 90_random_06.txt, 90_random_07.txt, 90_random_08.txt, 90_random_09.txt, 99_medium_00.txt
Case Name
Status
Exec Time
Memory
00_sample_00.txt
AC
1 ms
256 KB
00_sample_01.txt
AC
1 ms
256 KB
00_sample_02.txt
AC
1 ms
256 KB
00_sample_03.txt
AC
1 ms
256 KB
01_max_00.txt
AC
56 ms
256 KB
01_max_01.txt
AC
55 ms
256 KB
05_corner_00.txt
AC
1 ms
256 KB
05_corner_01.txt
AC
1 ms
256 KB
05_corner_02.txt
WA
1 ms
256 KB
10_min_00.txt
AC
1 ms
256 KB
10_min_01.txt
AC
1 ms
256 KB
10_min_02.txt
AC
1 ms
256 KB
10_wrong_answer_00.txt
WA
1 ms
256 KB
20_max_00.txt
AC
52 ms
256 KB
20_max_01.txt
AC
50 ms
256 KB
20_max_02.txt
AC
50 ms
256 KB
90_random_00.txt
AC
1 ms
256 KB
90_random_01.txt
AC
49 ms
256 KB
90_random_02.txt
AC
1 ms
256 KB
90_random_03.txt
AC
1 ms
256 KB
90_random_04.txt
WA
1 ms
256 KB
90_random_05.txt
WA
1 ms
256 KB
90_random_06.txt
AC
49 ms
256 KB
90_random_07.txt
AC
1 ms
256 KB
90_random_08.txt
AC
1 ms
256 KB
90_random_09.txt
AC
13 ms
256 KB
99_medium_00.txt
WA
1 ms
256 KB