Submission #35610311


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
const int mxn=1e5+10;
int n,m,k,a1,a2;
vector<int>ver[mxn];
int f[mxn],a[mxn],b[mxn];
struct node{
int p,w;
friend bool operator < (const node a,const node b) {return a.w>b.w;}
}; priority_queue<node>q; bool vis[mxn];
int main()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=m;i++)
{
scanf("%d%d",&a1,&a2);
ver[a1].push_back(a2); ver[a2].push_back(a1);
}
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=k;i++) scanf("%d",&b[i]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
const int mxn=1e5+10;

int n,m,k,a1,a2;
vector<int>ver[mxn];
int f[mxn],a[mxn],b[mxn];
struct node{
    int p,w;
    friend bool operator < (const node a,const node b) {return a.w>b.w;}
}; priority_queue<node>q; bool vis[mxn];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a1,&a2);
        ver[a1].push_back(a2); ver[a2].push_back(a1);
    }
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=k;i++) scanf("%d",&b[i]);
    memset(f,0x3f,sizeof(f));
    f[1]=(b[1]==a[1]); q.push(node{1,f[1]});
    while(!q.empty())
    {
        node ff=q.top(); q.pop(); int u=ff.p;
        if(vis[u]) continue; 
        vis[u]=1;
        for(int to:ver[u])
        {
            int w=(f[u]==k?k:f[u]+(b[f[u]+1]==a[to]));
            if(f[to]>w)
            {
                f[to]=w;
                q.push(node{to,f[to]});
            }
        }
    }
    if(f[n]==k) puts("Yes");
    else puts("No");
}   

Submission Info

Submission Time
Task C - Path and Subsequence
User cjh_hhz
Language C++ (GCC 9.2.1)
Score 500
Code Size 1044 Byte
Status AC
Exec Time 89 ms
Memory 11284 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d%d%d",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
./Main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   17 |         scanf("%d%d",&a1,&a2);
      |         ~~~~~^~~~~~~~~~~~~~~~
./Main.cpp:20:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   20 |     for(int i=1;i<=n;i++) scanf("%d",&a[i]);
      |                           ~~~~~^~~~~~~~~~~~
./Main.cpp:21:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   21 |     for(int i=1;i<=k;i++) scanf("%d",&b[i]);
      |                           ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 72
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-yes-001.txt, 01-yes-002.txt, 01-yes-003.txt, 01-yes-004.txt, 01-yes-005.txt, 01-yes-006.txt, 01-yes-007.txt, 01-yes-008.txt, 01-yes-009.txt, 01-yes-010.txt, 01-yes-011.txt, 01-yes-012.txt, 01-yes-013.txt, 01-yes-014.txt, 01-yes-015.txt, 01-yes-016.txt, 01-yes-017.txt, 01-yes-018.txt, 01-yes-019.txt, 01-yes-020.txt, 01-yes-021.txt, 01-yes-022.txt, 01-yes-023.txt, 01-yes-024.txt, 01-yes-025.txt, 02-no-001.txt, 02-no-002.txt, 02-no-003.txt, 02-no-004.txt, 02-no-005.txt, 02-no-006.txt, 02-no-007.txt, 02-no-008.txt, 02-no-009.txt, 02-no-010.txt, 02-no-011.txt, 02-no-012.txt, 02-no-013.txt, 02-no-014.txt, 02-no-015.txt, 02-no-016.txt, 02-no-017.txt, 02-no-018.txt, 02-no-019.txt, 02-no-020.txt, 02-no-021.txt, 02-no-022.txt, 02-no-023.txt, 02-no-024.txt, 02-no-025.txt, 03-test-001.txt, 03-test-002.txt, 03-test-003.txt, 03-test-004.txt, 03-test-005.txt, 03-test-006.txt, 03-test-007.txt, 03-test-008.txt, 03-test-009.txt, 04-strong-001.txt, 04-strong-002.txt, 04-strong-003.txt, 04-strong-004.txt, 04-strong-005.txt, 04-strong-006.txt, 04-strong-007.txt, 04-strong-008.txt, 04-strong-009.txt, 04-strong-010.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 9 ms 6356 KB
00-sample-002.txt AC 6 ms 6228 KB
00-sample-003.txt AC 5 ms 6384 KB
01-yes-001.txt AC 89 ms 10964 KB
01-yes-002.txt AC 86 ms 10984 KB
01-yes-003.txt AC 82 ms 11020 KB
01-yes-004.txt AC 75 ms 11204 KB
01-yes-005.txt AC 80 ms 11008 KB
01-yes-006.txt AC 80 ms 11092 KB
01-yes-007.txt AC 79 ms 10976 KB
01-yes-008.txt AC 83 ms 11148 KB
01-yes-009.txt AC 79 ms 10960 KB
01-yes-010.txt AC 77 ms 11176 KB
01-yes-011.txt AC 79 ms 10956 KB
01-yes-012.txt AC 79 ms 11172 KB
01-yes-013.txt AC 81 ms 11140 KB
01-yes-014.txt AC 77 ms 11128 KB
01-yes-015.txt AC 81 ms 11108 KB
01-yes-016.txt AC 79 ms 11012 KB
01-yes-017.txt AC 79 ms 11044 KB
01-yes-018.txt AC 79 ms 11128 KB
01-yes-019.txt AC 80 ms 11188 KB
01-yes-020.txt AC 81 ms 11168 KB
01-yes-021.txt AC 80 ms 11104 KB
01-yes-022.txt AC 83 ms 11016 KB
01-yes-023.txt AC 81 ms 11096 KB
01-yes-024.txt AC 79 ms 11096 KB
01-yes-025.txt AC 79 ms 10880 KB
02-no-001.txt AC 78 ms 10884 KB
02-no-002.txt AC 76 ms 10900 KB
02-no-003.txt AC 82 ms 10972 KB
02-no-004.txt AC 76 ms 11228 KB
02-no-005.txt AC 79 ms 10980 KB
02-no-006.txt AC 81 ms 10996 KB
02-no-007.txt AC 81 ms 11224 KB
02-no-008.txt AC 80 ms 11116 KB
02-no-009.txt AC 81 ms 11132 KB
02-no-010.txt AC 76 ms 11132 KB
02-no-011.txt AC 83 ms 11104 KB
02-no-012.txt AC 79 ms 11284 KB
02-no-013.txt AC 84 ms 10996 KB
02-no-014.txt AC 78 ms 11168 KB
02-no-015.txt AC 78 ms 10992 KB
02-no-016.txt AC 79 ms 11168 KB
02-no-017.txt AC 81 ms 11176 KB
02-no-018.txt AC 78 ms 11020 KB
02-no-019.txt AC 80 ms 11180 KB
02-no-020.txt AC 78 ms 11136 KB
02-no-021.txt AC 76 ms 10840 KB
02-no-022.txt AC 80 ms 10964 KB
02-no-023.txt AC 84 ms 10928 KB
02-no-024.txt AC 78 ms 10840 KB
02-no-025.txt AC 80 ms 10932 KB
03-test-001.txt AC 5 ms 6244 KB
03-test-002.txt AC 5 ms 6368 KB
03-test-003.txt AC 49 ms 10084 KB
03-test-004.txt AC 54 ms 10164 KB
03-test-005.txt AC 70 ms 9932 KB
03-test-006.txt AC 65 ms 10080 KB
03-test-007.txt AC 71 ms 10172 KB
03-test-008.txt AC 49 ms 10364 KB
03-test-009.txt AC 48 ms 10232 KB
04-strong-001.txt AC 65 ms 10096 KB
04-strong-002.txt AC 65 ms 10164 KB
04-strong-003.txt AC 69 ms 10240 KB
04-strong-004.txt AC 65 ms 10204 KB
04-strong-005.txt AC 63 ms 10148 KB
04-strong-006.txt AC 59 ms 10064 KB
04-strong-007.txt AC 62 ms 10212 KB
04-strong-008.txt AC 58 ms 9908 KB
04-strong-009.txt AC 64 ms 10144 KB
04-strong-010.txt AC 59 ms 10060 KB


2025-03-17 (Mon)
02:19:52 +00:00