absi2011's Blog & Daily Life.

全新的开始       我要省选翻盘       I wanna AK in 高考\化学       自此,生无可恋
POJ 3910 碎碎念

100202 H 碎碎念

absi2011 posted @ 9 年前 in 个人感想 with tags 碎碎念 CF Gym 杂文 , 346 阅读

醉了

写了398行了,总是WA on test 10

不知道该怎么办了

最近一切的一切都不是那么的顺呢

不知道为什么呢

回想起来,我这NOIP是第三次挂了

分组赛,NOI,NOIP

状态还没有恢复么,不会之后来不及了吧?

写到醉了

wjh带我翻译我得写出来再说啊...

不过还是特别鸣谢wjh啦

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<math.h>
#include<string>
#include<time.h>
#include<bitset>
#include<vector>
#include<memory>
#include<utility>
#include<stdio.h>
#include<sstream>
#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[1005];
char stop_flag;
void read()
{
    char x;
    for (;;)
    {
        x=getchar();
        if (x!=' ') break;
    }
    int sum=1;
    a[0]=x;
    for (;;)
    {
        a[sum]=getchar();
        if ((a[sum]=='\n')||(a[sum]==',')||(a[sum]==-1))
        {
            stop_flag=a[sum];
            for (;(a[sum-1]==' ')||(a[sum-1]=='\r');)
            {
                sum--;
            }
            a[sum]='\0';
            return;
        }
        sum++;
    }
}
map<string,int> ma;
string room[15];
int x[65],y[65];
string key[65];
struct character
{
    string name;
    int need[205];
    int offer[205];
};
character b[15][205];
struct object
{
    string name;
    int need[205];
    int offer[205];
};
object c[15][205];
int d[15][205];
string items[205];
map<string,int> item;
bool visit[15];
int open[65];
bool can_visit[15];
int own[205];
int n;
int m;
int get_num()
{
    static int sum=0;
    string b=a;
    if (item.find(b)==item.end())
    {
        item[b]=sum;
        items[sum]=b;
        sum++;
    }
    return item[b];
}
void dfss(int now,int goal,int flag=0)
{
    if (!flag) printf("go to %s\n",room[now].c_str());
    if (visit[now]) return;
    visit[now]=true;
    if (now==goal) return;
    int i;
    for (i=0;i<m;i++)
    {
        if (!open[i]) continue;
        if (x[i]==now)
        {
            dfss(y[i],goal);
            if (visit[goal]) return;
            printf("go to %s\n",room[now].c_str());
        }
        if (y[i]==now)
        {
            dfss(x[i],goal);
            if (visit[goal]) return;
            printf("go to %s\n",room[now].c_str());
        }
    }
}
void dfs(int x,int y)
{
    memset(visit,false,sizeof(visit));
    dfss(x,y,1);
}
int main()
{
    freopen("quest.in","r",stdin);
    freopen("quest.out","w",stdout);
    ios::sync_with_stdio(false);
    scanf("%d",&n);
    int i;
    getchar();
    for (i=0;i<n;i++)
    {
        read();
        room[i]=a;
        ma[a]=i;
    }
    scanf("%d",&m);
    for (i=0;i<m;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
        x[i]--;
        y[i]--;
        read();
        key[i]=a;
        get_num();
    }
    for (i=0;i<n;i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        getchar();
        int j;
        for (j=0;j<x;j++)
        {
            int t=0;
            read();
            b[i][j].name=a;
            for (;;)
            {
                read();
                b[i][j].need[t++]=get_num();
                if (stop_flag=='\n') break;
            }
            b[i][j].need[t]=-1;
            t=0;
            for (;;)
            {
                read();
                b[i][j].offer[t++]=get_num();
                if (stop_flag=='\n') break;
            }
            b[i][j].offer[t]=-1;
        }
        for (j=0;j<y;j++)
        {
            int t=0;
            read();
            c[i][j].name=a;
            for (;;)
            {
                read();
                c[i][j].need[t++]=get_num();
                if (stop_flag=='\n') break;
            }
            c[i][j].need[t]=-1;
            t=0;
            for (;;)
            {
                read();
                c[i][j].offer[t++]=get_num();
                if (stop_flag=='\n') break;
            }
            c[i][j].offer[t]=-1;
        }
        for (j=0;j<z;j++)
        {
            read();
            d[i][j]=get_num();
        }
        d[i][z]=-1;
    }
    read();
    int start=ma[a];
    read();
    int end=ma[a];
    can_visit[start]=true;
    //can_do_list:
    //1,go to another room(with key)
    //2,pick up something
    //3,talk to a character or use object
    memset(own,0,sizeof(own));
    int now=start;
    for (;;)
    {
        if (can_visit[end])
        {
            dfs(now,end);
            printf("save princess\n");
            return 0;
        }
        int i;
        for (i=0;i<m;i++)
        {
            if ((own[i])&&((can_visit[x[i]])^(can_visit[y[i]])))
            {
                if (can_visit[x[i]])
                {
                    dfs(now,x[i]);
                    now=x[i];
                    printf("open door to %s\n",room[y[i]].c_str());
                    can_visit[y[i]]=true;
                    open[i]=true;
                    break;
                }
                if (can_visit[y[i]])
                {
                    dfs(now,y[i]);
                    now=y[i];
                    printf("open door to %s\n",room[x[i]].c_str());
                    can_visit[x[i]]=true;
                    open[i]=true;
                    break;
                }
            }
        }
        if (i!=m) continue;
        for (i=0;i<n;i++)
        {
            if (can_visit[i])
            {
                if (d[i][0]==-1) continue;
                dfs(now,i);
                now=i;
                int j;
                for (j=0;d[i][j]!=-1;j++)
                {
                    printf("pick %s\n",items[d[i][j]].c_str());
                    own[d[i][j]]=true;
                }
                d[i][0]=-1;
                break;
            }
        }
        if (i!=n) continue;
        for (i=0;i<n;i++)
        {
            if (can_visit[i])
            {
                int j;
                for (j=0;b[i][j].name.length()!=0;j++)
                {
                    if (b[i][j].need[0]==-1) continue;
                    int k;
                    for (k=0;b[i][j].need[k]!=-1;k++)
                    {
                        if (!own[b[i][j].need[k]])
                        {
                            break;
                        }
                    }
                    if (b[i][j].need[k]==-1)
                    {
                        dfs(now,i);
                        now=i;
                        printf("talk to %s\n",b[i][j].name.c_str());
                        int k;
                        printf("give");
                        for (k=0;b[i][j].need[k]!=-1;k++)
                        {
                            if (k==0)
                            {
                                printf(" ");
                            }
                            else if (b[i][j].need[k+1]==-1)
                            {
                                printf(" and ");
                            }
                            else
                            {
                                printf(", ");
                            }
                            printf("%s",items[b[i][j].need[k]].c_str());
                        }
                        printf(" to %s\n",b[i][j].name.c_str());
                        printf("take");
                        for (k=0;b[i][j].offer[k]!=-1;k++)
                        {
                            own[b[i][j].offer[k]]=true;
                            if (k==0)
                            {
                                printf(" ");
                            }
                            else if (b[i][j].offer[k+1]==-1)
                            {
                                printf(" and ");
                            }
                            else
                            {
                                printf(", ");
                            }
                            printf("%s",items[b[i][j].offer[k]].c_str());
                        }
                        printf(" from %s\n",b[i][j].name.c_str());
                        b[i][j].need[0]=-1;
                        break;
                    }
                }
                if (b[i][j].name.length()!=0) break;
            }
        }
        if (i!=n) continue;
        for (i=0;i<n;i++)
        {
            if (can_visit[i])
            {
                int j;
                for (j=0;c[i][j].name.length()!=0;j++)
                {
                    if (c[i][j].need[0]==-1) continue;
                    int k;
                    for (k=0;c[i][j].need[k]!=-1;k++)
                    {
                        if (!own[c[i][j].need[k]])
                        {
                            break;
                        }
                    }
                    if (c[i][j].need[k]==-1)
                    {
                        dfs(now,i);
                        now=i;
                        int k;
                        printf("use");
                        for (k=0;c[i][j].need[k]!=-1;k++)
                        {
                            own[c[i][j].offer[k]]=true;
                            if (k==0)
                            {
                                printf(" ");
                            }
                            else if (c[i][j].need[k+1]==-1)
                            {
                                printf(" and ");
                            }
                            else
                            {
                                printf(", ");
                            }
                            printf("%s",items[c[i][j].need[k]].c_str());
                        }
                        printf(" on %s\n",c[i][j].name.c_str());
                        printf("take");
                        for (k=0;c[i][j].offer[k]!=-1;k++)
                        {
                            if (k==0)
                            {
                                printf(" ");
                            }
                            else if (c[i][j].offer[k+1]==-1)
                            {
                                printf(" and ");
                            }
                            else
                            {
                                printf(", ");
                            }
                            printf("%s",items[c[i][j].offer[k]].c_str());
                        }
                        printf(" from %s\n",c[i][j].name.c_str());
                        c[i][j].need[0]=-1;
                        break;
                    }
                }
                if (c[i][j].name.length()!=0) break;
            }
        }
        if (i!=n) continue;
        break;
    }
    freopen("quest.out","w",stdout);
    printf("dead princess\n");
    return 0;
}

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter