pta天梯赛链表去重问题 已经成功ac

https://pintia.cn/problem-sets/994805046380707840/problems/994805072641245184


#include 
using namespace std;
const int maxsize=100000;
bool visit[maxsize]={false};//都没有出现过
struct Lnode
{
     int data;
     int next;

};
struct L
{
     int s1;
     int s2;
     int s3;

};
struct Lnode node[maxsize];//用下表作为地址存放节点的值以及
struct L a[maxsize];
struct L b[maxsize];//存放删除的重复的结点
int main()
{
   int n,head;
  int k1=0,k2=0;
   cin>>head>>n;
   int t1,t2,t3;
   for(int i=0;i>t1>>t2>>t3;
       node[t1].data=t2;
       node[t1].next=t3;

   }
   while(head!=-1)
   {
       if(visit[abs(node[head].data)]==false)
       {
           a[k1].s1=head;
           a[k1].s2=node[head].data;
           a[k1].s3=node[head].next;
           k1++;
           visit[abs(node[head].data)]=true;
       }
       else
       {
           b[k2].s1=head;
           b[k2].s2=node[head].data;
           b[k2].s3=node[head].next;
           k2++;

       }
     head=node[head].next;

   }
   if(k1>=1)
   a[k1-1].s3=-1;
   if(k2>=1)
   b[k2-1].s3=-1;
   for(int i=0;i

 

你可能感兴趣的:(pta天梯赛链表去重问题 已经成功ac)