提出 #3204080
ソースコード 拡げる
/* Worldwide Combos, free and competitive block-stacking game!
https://www.worldwide-combos.com */
#include<iostream>
#include<vector>
#include<array>
#include<string>
#include<sstream>
#include<map>
#include<unordered_map>
#include<chrono>
#include<set>
#include<unordered_set>
#include<ctime>
#include<bitset>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<random>
#include<cassert>
#include<complex>
#include<fstream>
#include<pthread.h>
#pragma GCC optimize "-O3"
#pragma GCC target "tune=native"
#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = b-1; i >= a; i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define si(n) scanf("%d", &n)
#define sii(n,m) scanf("%d %d", &n, &m)
#define siii(n,m,k) scanf("%d %d %d", &n, &m, &k)
#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf("%c", &c)
#define ss(s) scanf("%s", s)
#define sai(t,n) fin(iz,n) { scanf("%d", &t[iz]); }
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pi(n) printf("%d\n", n)
#define pii(n,m) printf("%d %d\n", n, m)
#define piii(n,m,k) printf("%d %d %d\n", n, m, k)
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pai(t,n) fin(rz,n) { printf("%d ", t[rz]); } printf("\n")
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")
#define L long long int
#define D double
#define PII pair<int, int>
#define VPII vector<PII>
#define VL vector<L>
#define VI vector<int>
#define VVI vector<VI>
#define VD vector<D>
#define VVD vector<VD>
#define VVPII vector<VPII>
#define VC vector<char>
using namespace std;
int a[200200] = {0}, b[200200] = {0};
int vu[200200] = {0};
VI g[200200];
int rep = 1;
char st[200200];
int ra = 0, rb = 0;
int da = 0, db = 0;
void visiter(int s) {
//pi(s);
if (st[s] == 'B') { rb = 1; }
else { ra = 1; }
//pi(s);
//pii(ra, rb);
vu[s] = 1;
int ok1 = 0, ok2 = 0;
fin(i, g[s].size()) {
if (st[g[s][i]] == 'A' && a[g[s][i]] == 1 && b[g[s][i]] == 1) { ok1 = 1; }
if (st[g[s][i]] == 'B' && a[g[s][i]] == 1 && b[g[s][i]] == 1) { ok2 = 1; }
if (vu[g[s][i]] == 0 && a[g[s][i]] == 1 && b[g[s][i]] == 1) { visiter(g[s][i]); }
}
if (ok1+ok2 < 2) { rep = 0; }
}
int main() {
int n, m;
sii(n, m);
ss(st);
int u, v;
fin(i, m) {
sii(u, v);
u--; v--;
if (st[v] == 'A') { a[u] = 1; }
else { b[u] = 1; }
if (st[u] == 'A') { a[v] = 1; }
else { b[v] = 1; }
g[u].pb(v);
g[v].pb(u);
}
fin(i, n) {
//ps("###");
if (vu[i] == 0 && a[i] == 1 && b[i] == 1) { rep = 1; visiter(i); }
if (st[i] == 'A' && rep == 1 && ra == 1 && rb == 1) { da = 1; return 0; }
if (st[i] == 'B' && rep == 1 && ra == 1 && rb == 1) { db = 1; return 0; }
rep = 0;
ra = 0;
rb = 0;
}
if (da+db == 2) { ps("Yes"); return 0; }
ps("No");
}
int main2() {
//freopen("assessment.in", "r", stdin);
//freopen("output.txt", "w", stdout);
int n;
D a[200200];
D x;
si(n);
sd(x);
sad(a, n);
D res[2001] = {0};
ford(i, n) {
D s = 5*a[i] + 2*x;
D t = 0;
if (i == n-1) { res[i] = s; }
else {
res[i] = s + res[i+1];
s += 5*a[i+1] + x;
res[i] = min(res[i], s + res[i+2]);
}
fin2(j, i+2, n) {
t += a[j-2];
s += 5*a[j] + x + 2*t;
res[i] = min(res[i], s + res[j+1]);
}
}
printf("%.0lf\n", res[0]);
/*D r = ((D) n)*100;
D s = -x, t = 0;
if (n == 1) { s = 0; }
int d = 0;
fin2(i, 2, n) {
t += a[i-2];
if (2*t > x) {
D q = 0;
fin2(j, d, i) {
q += a[j];
}
r += 5*q + (i-d)*x + s;
d = i;
t = 0;
i++;
if (i < n) { s = -x; }
}
else { s += 2*t-x; }
}
D q = 0;
fin2(j, d, n) {
q += a[j];
}
r += 5*q + (n-d)*x + s;
printf("%.0lf\n", r);*/
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
C - ABland Yard |
| ユーザ |
noelnadal |
| 言語 |
C++14 (GCC 5.4.1) |
| 得点 |
0 |
| コード長 |
5148 Byte |
| 結果 |
WA |
| 実行時間 |
84 ms |
| メモリ |
17920 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:116:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sii(n, m);
^
./Main.cpp:117:11: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
ss(st);
^
./Main.cpp:120:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sii(u, v);
^
./Main.cpp: In function ‘int main2()’:
./Main.cpp:148:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
si(n);
^
./Main.cpp:149:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sd(x);
^
./Main.cpp:56:50: warning: ignoring return value of ‘int scanf(const ch...
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 900 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt |
| All |
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| sample_01.txt |
WA |
3 ms |
6144 KiB |
| sample_02.txt |
AC |
3 ms |
6144 KiB |
| sample_03.txt |
WA |
3 ms |
6144 KiB |
| sample_04.txt |
AC |
3 ms |
6144 KiB |
| test_01.txt |
WA |
71 ms |
14336 KiB |
| test_02.txt |
AC |
70 ms |
16896 KiB |
| test_03.txt |
WA |
41 ms |
12928 KiB |
| test_04.txt |
WA |
59 ms |
16640 KiB |
| test_05.txt |
AC |
50 ms |
14336 KiB |
| test_06.txt |
WA |
40 ms |
12416 KiB |
| test_07.txt |
WA |
22 ms |
9216 KiB |
| test_08.txt |
WA |
40 ms |
12928 KiB |
| test_09.txt |
AC |
31 ms |
10112 KiB |
| test_10.txt |
AC |
21 ms |
8960 KiB |
| test_11.txt |
WA |
70 ms |
15488 KiB |
| test_12.txt |
WA |
71 ms |
17920 KiB |
| test_13.txt |
AC |
42 ms |
12544 KiB |
| test_14.txt |
WA |
58 ms |
14208 KiB |
| test_15.txt |
AC |
52 ms |
14976 KiB |
| test_16.txt |
WA |
22 ms |
7296 KiB |
| test_17.txt |
WA |
29 ms |
8192 KiB |
| test_18.txt |
WA |
23 ms |
7552 KiB |
| test_19.txt |
WA |
37 ms |
8064 KiB |
| test_20.txt |
WA |
30 ms |
8576 KiB |
| test_21.txt |
WA |
36 ms |
8832 KiB |
| test_22.txt |
WA |
62 ms |
11648 KiB |
| test_23.txt |
WA |
45 ms |
10112 KiB |
| test_24.txt |
WA |
76 ms |
12544 KiB |
| test_25.txt |
WA |
58 ms |
10880 KiB |
| test_26.txt |
WA |
84 ms |
13440 KiB |
| test_27.txt |
AC |
41 ms |
9984 KiB |
| test_28.txt |
AC |
21 ms |
8704 KiB |
| test_29.txt |
WA |
57 ms |
11008 KiB |
| test_30.txt |
WA |
18 ms |
7424 KiB |
| test_31.txt |
WA |
63 ms |
11904 KiB |
| test_32.txt |
AC |
42 ms |
10624 KiB |
| test_33.txt |
WA |
79 ms |
12800 KiB |
| test_34.txt |
AC |
16 ms |
7552 KiB |
| test_35.txt |
WA |
83 ms |
13568 KiB |
| test_36.txt |
AC |
3 ms |
6144 KiB |
| test_37.txt |
AC |
3 ms |
6144 KiB |
| test_38.txt |
AC |
3 ms |
6144 KiB |
| test_39.txt |
WA |
3 ms |
6144 KiB |
| test_40.txt |
AC |
3 ms |
6144 KiB |
| test_41.txt |
AC |
3 ms |
6144 KiB |
| test_42.txt |
WA |
3 ms |
6144 KiB |
| test_43.txt |
WA |
3 ms |
6144 KiB |
| test_44.txt |
WA |
3 ms |
6144 KiB |
| test_45.txt |
WA |
3 ms |
6144 KiB |
| test_46.txt |
AC |
3 ms |
6144 KiB |
| test_47.txt |
AC |
3 ms |
6144 KiB |
| test_48.txt |
AC |
3 ms |
6144 KiB |
| test_49.txt |
WA |
3 ms |
6144 KiB |
| test_50.txt |
WA |
3 ms |
6144 KiB |
| test_51.txt |
AC |
3 ms |
6144 KiB |
| test_52.txt |
WA |
3 ms |
6144 KiB |
| test_53.txt |
AC |
3 ms |
6144 KiB |
| test_54.txt |
WA |
3 ms |
6144 KiB |
| test_55.txt |
AC |
3 ms |
6144 KiB |